Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: aholla on May 28, 2014, 09:52:02 AM

Title: TweenScale and UIButton scale overriding...
Post by: aholla on May 28, 2014, 09:52:02 AM
Hi I have a UIButtonScale component and it works, but if I try and tween the button via code using the "From" properties, the UIButton Tween gets reset.

Example: I tween my button in from 0 to 1 (TweenScale). Then on "hover" i tween the scale to 1.2 (UIButtonScale).

Prior to adding the TweenScale from 0 -1 the hover worked but with the 0-1, when I hover, it now tweens the button back to 0 instead of the 1.2 that I have set.

  1. TweenScale tween = UITweener.Begin<TweenScale>( go, 1.0f );
  2. tween.from = new Vector3( 0.0f, 0.0f, 0.0f );  
  3. tween.to = new Vector3( 1.0f, 1.0f, 1.0f );
  4.  

Is there a way to override this setting and is it a bug? I presume the UITweener keeps all its values for the game object so need to reset it or unlink it from my gameobject....


On closer inspection there are a few other things that dont seem right...

I have tried setting my hover scale to 2.0. This seems to work but when I look at the inspector at the dynamically added "TweenScale" (which returns the buttons scale on the mouse out) it shows From "1.8" To 0.9. And my button is smaller than it should be. I would expect the numbers to be 2.0 and 1.0. Why is this?
Title: Re: TweenScale and UIButton scale overriding...
Post by: ArenMook on May 29, 2014, 05:57:09 AM
Well first, scale of zero is invalid. You can't divide by zero, so inverse matrices can't be calculated properly. Use a small value instead such as 0.01.

Next, you are starting the tween wrong. It should be TweenScale.Begin(go, duration, targetScale);

There is no need to specify the "from". The "from" is just the current scale by default.