- Home /
Gliding a GUI Element in...
Does Lerp work for OnGUI to glide a GUI element into view?
Comment
Answer by GlennHeckman · Apr 30, 2011 at 05:59 AM
Here's a Unity thread about Lerping a GUI element .. compliments of Google: Animating GUI movement?
Answer by dentedpixel · Apr 23, 2013 at 12:33 PM
To make things even easier you could use the animation engine LeanTween and accomplish this with very little code:
public var grumpy:Texture2D;
private var grumpyRect:LTRect;
function Start () {
grumpyRect = new LTRect( -grumpy.width, 0.5*Screen.height - grumpy.height/2.0, grumpy.width, grumpy.height );
// Slide in
LeanTween.move(grumpyRect, new Vector2(0.5*Screen.width - grumpy.width/2.0, grumpyRect.rect.y ), 1.0, {"ease":LeanTween.easeOutQuad});
}
function OnGUI(){
GUI.DrawTexture( grumpyRect.rect, grumpy);
}
There are more advanced examples here.