1 GUITest0
function OnGUI() { GUI.Label(Rect(10,10,100,30),"ChooseLevel"); //Debug.Log("Clicked the button with an image"); if (GUI.Button(Rect(10,70,50,30),"1")) //Debug.Log("Clicked the button with text"); {Application.LoadLevel(1);}//申请载入场景1 }
2GUITest1
function OnGUI() { if (GUI.Button(Rect(700,500,50,30),"Right")) //Debug.Log("Clicked the button with an image"); {animation.CrossFade("Right");} if (GUI.Button(Rect(500,500,50,30),"Left")) //Debug.Log("Clicked the button with text"); {animation.CrossFade("Left");} if (GUI.Button(Rect(800,800,50,30),"Back")) //Debug.Log("Clicked the button with text"); {Application.LoadLevel(0);}//申请载入场景0 }
注:通过点击GUIButton 实现播放动画,场景的切换.场景0和1的确定是在File-Build Settings 把2个场景拖入到Scenes In Build