- Home /
make buttons appear slowly
I want to make three buttons to appear slowly,can anybody tell me?
using UnityEngine; using System.Collections;
public class Test3 : MonoBehaviour {
// Use this for initialization void Start () {
}
// Update is called once per frame void Update () { } Rect button=new Rect(100,100,100,100); Rect from=new Rect(100,100,100,100); bool isShow=true; Rect to =new Rect(25,30,250,30); void OnGUI(){
GUI.BeginGroup(new Rect(20,20,300,300));
ChangePosition();
if(!isShow)
ShowMenu();
GUI.Box(new Rect(0,0,300,300)," ");
GUI.EndGroup();
} void function(Rect r){ button=r; } Color colorfrom=new Color(1,1,1,0); Color colorto=new Color(1,1,1,1); void ShowMenu(){ GUI.BeginGroup(new Rect(50,70,250,200)); GUILayout.BeginVertical(GUILayout.Width(250),GUILayout.Height(200)); GUILayout.Button("button1",GUILayout.Width(200),GUILayout.Height(30)); GUILayout.Button("button2",GUILayout.Width(200),GUILayout.Height(30)); GUILayout.Button("button3",GUILayout.Width(200),GUILayout.Height(30)); GUILayout.EndVertical(); GUI.EndGroup(); } void ChangePosition(){ if(GUI.Button(button,"Menu")){ if(isShow){ iTween.ValueTo(gameObject.gameObject,iTween.Hash("from",button,"to",to,"easeType",iTween.EaseType.easeInOutBack,"onupdate","function"));
}
else
{
iTween.ValueTo(this.gameObject,iTween.Hash("from",button,"to",from,"easeType",iTween.EaseType.easeInOutBack,"onupdate","function"));
}
isShow=!isShow;
} } void ChangeColor(Color c){ colorfrom=c; }
}
Answer by SirGive · Sep 28, 2010 at 10:32 AM
You could set the Alpha property to 0 initially, and then increase it at some rate in the update function until alpha reaches 1.
Your answer
Follow this Question
Related Questions
Fading all but single instance of a button 1 Answer
fade a button 1 Answer
How to change a color of a GUI Button on click 2 Answers
OnSelect and OnPointerEnter work in one script but not another on the same object 2 Answers
How to preserve image quality when putting image on a cube for buttons 1 Answer