Author Topic: Using / Reusing TweenScale : UITweener  (Read 5090 times)

Rory Pickering

  • Guest
Using / Reusing TweenScale : UITweener
« on: February 21, 2013, 07:01:49 AM »
Hello, What I am trying to achieve is the following:
  • Add Sprite
  • Animate Scale in
  • wait for user interaction
  • Animate Scale out

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
« Last Edit: February 21, 2013, 07:05:00 AM by Rory Pickering »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Using / Reusing TweenScale : UITweener
« Reply #1 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.

Rory Pickering

  • Guest
Re: Using / Reusing TweenScale : UITweener
« Reply #2 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.

AtomicBob

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 69
    • View Profile
Re: Using / Reusing TweenScale : UITweener
« Reply #3 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.