I discover iTween today and find it can save me time for some GUI animations. But originally I use UnityGUI to do GUI stuff instead of GUITexture objects. Any way to use iTween on UnityGUI? Thanks.
If you are looking to animate GUI elements I would recommend using the tweening engine LeanTween. It works with Rects and allows you to do animations with much less code (compared to using a bunch of ValueTo’s in iTween). Here is an example of scaling a button:
// Javascript Code
private var bRect:LTRect = new LTRect( 0, 0, 100, 50 );
function OnGUI(){
if(GUI.Button(bRect.rect, “Scale”)){
LeanTween.scale( bRect, Vector2(bRect.rect.width, bRect.rect.height) * 1.3, 0.25 );
}
}
// C# Code
private LTRect bRect = new LTRect( 0f, 0f, 100f, 50f );
void OnGUI(){
if(GUI.Button(bRect.rect, “Scale”)){
LeanTween.scale( bRect, new Vector2(bRect.rect.width, bRect.rect.height) * 1.3f, 0.25f );
}
}
You can find more detailed examples of animating GUI Elements here: http://dentedpixel.com/developer-diary/animate-unity-gui-elements-with-ease/
As there is no function specifically for rects, you’ll need to use ValueTo with a function that takes a rect parameter.