Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Rory Pickering on February 21, 2013, 07:01:49 AM

Title: Using / Reusing TweenScale : UITweener
Post by: Rory Pickering on February 21, 2013, 07:01:49 AM
Hello, What I am trying to achieve is the following:

void AddSequencePoint(Vector3 position)
{
   UISprite sequencePoint = NGUITools.AddSprite(container.gameObject, atlas, "point");
   sequencePoint.cachedTransform.localPosition = position;
   points.Add (sequencePoint);
   sequencePoint.cachedTransform.localScale = new Vector3(0f, 0f, 0f);
   TweenScale scale = TweenScale.Begin(sequencePoint.gameObject, 1f, new Vector3( 1f, 1f, 1f) );   
}

public void AnimateSequencePointOut(int index)
{
   GameObject go = points[index].gameObject;
        TweenScale scale = TweenScale.Begin(go, 0.3f, new Vector3( 0f, 0f, 0f) );
   scale.animationCurve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(0.3f, -0.1f, 0.2f, 0.7f), new Keyframe(1f, 1f, 1f, 0f));
}


Renders the points on the screen at a size of 0,0 and never animates it up. If i view the object within the inspector, all of the values are tweening, but nothing changes on screen?

Thanks in advance
Title: Re: Using / Reusing TweenScale : UITweener
Post by: ArenMook on February 21, 2013, 10:52:54 PM
Size 0 is invalid. You can't divide by zero. Use a small number instead such as 0.01.
Title: Re: Using / Reusing TweenScale : UITweener
Post by: Rory Pickering on February 22, 2013, 05:19:04 AM
I thought you would say that, as I saw a post with a similar problem with that response. This is not the case, as i have tried it with other values than 0, the numbers animate within the inspector.
Title: Re: Using / Reusing TweenScale : UITweener
Post by: AtomicBob on February 22, 2013, 12:59:10 PM
I was just searching for information on what appears to be the same issue. Using a small number instead of 0 fixed the problem for me. I've been using tweening from 0 to 1 for a lot of stuff and only have had an issue in a small number of cases. It works fine 9 times out of 10, but there seems to be a few situations where it chokes. In particular, I've noticed if I have a TweenScale and UIPanel script on the same GameObject, the tweening happens but the textures are not drawn.

On a side note, changing my tween values from 0 to small numbers makes the animation extremely jerky. I'm only seeing 2-3 updates.