#pragma strictprivate var m_pcubeobj:gameobject = null;private var m_pmeshfilter:meshfilter = null;public var m_fTrams Latespeed:float = 20.0f;public var m_frotatespeed:float = 60.0f;function Ongui () {GUI. Label (New Rect (0.0f,0.0f,screen.width,20.0f), "This is my first GUI"), if (GUI. button (new Rect (5.0f,30.0,100.0f,40.0f), "click Me")) {m_pcubeobj = Gameobject.createprimitive (Primitivetype.cube); /Create a cubeif (null! = m_pcubeobj) {m_pCubeObj.transform.position = new Vector3 (1.0f,2.0f,0.0f);}} if (GUI. button (new Rect (5.0f,170.0f,100.0f,40.0f), "move forward") {M_pCubeObj.transform.Translate (Vector3.forward * Time.deltatime * m_ftramslatespeed);} if (GUI. button (new Rect (115.0f,170.0f,100.0f,40.0f), "move Backwards") {M_pCubeObj.transform.Translate (Vector3.forward * Time.deltatime *-m_ftramslatespeed);} if (GUI. button (new Rect (225.0f,170.0f,100.0f,40.0f), "move Left") {m_pCubeObj.transform.Translate (Vector3.left * time.deltatime * m_ftramslatespeed);} if (GUI. button (new Rect (335.0f,170.0f,100.0f,40.0f), "move Right") {m_pcubeobj.Transform. Translate (Vector3.left * time.deltatime *-m_ftramslatespeed);//vector.right}if (GUI. button (new Rect (5.0f,220.0f,100.0f,40.0f), "rotate Left") {m_pCubeObj.transform.Rotate (vector3.up * time.deltatime *-m_ Frotatespeed);} if (GUI. button (new Rect (115.0f,220.0f,100.0f,40.0f), "rotate Right") {m_pCubeObj.transform.Rotate (vector3.up * time.deltatime * m_ frotatespeed);}}
Unity3d the path to cultivation: GUI buttons are simple to use, complete the movement of a simple object cube, rotate