Game Development Reference
In-Depth Information
}
//Draw our background character texture
GUI.DrawTexture(r_hero, t_hero);
//We create a close button here
if (GUI.Button (r_closeBtn, "", GUI.skin.GetStyle("Exit
Button"))) {
b_openMenu = false;
}
//Make our window dragable in whole area
GUI.DragWindow();
}
Since we want everything inside our menu window, we used the DoMyWindow
funcion to take a GUI.Window as one parameter. Inside the DoMyWindow funcion,
we create all the butons and textures. Then, we make our window draggable by
adding GUI.DragWindow() . With that we are done with coding for this step.
8. Next, go back to Unity , click on Menu.js , and drag-and-drop it to the Menu game
object in the Hierarchy . Next, click on the Menu game object in the Hierarchy , open
the Menu (Script) , and set the parameters as follows:
Custom Skin : Drag-and-drop our MenuSkin ( GUISkin ) here
T_hero : Drag-and-drop blackDude.png from the Chapter2/images
folder here
T_status Box 1 : Drag-and-drop stat1.png from the Chapter2/images
folder here
T_status Box 2 : Drag-and-drop stat2.png from the Chapter2/images
folder here
T_skill Box : Drag-and-drop skill0.pn g from the Chapter2/images
folder here
9. Then, we can click on the play buton to see the result. In the game scene, we can
press the M key to bring up our window and click the x buton at the top-right
corner to close it.
 
Search WWH ::




Custom Search