Game Development Reference
In-Depth Information
6. Next, we will use the OnGUI funcion to create our window.
OnGUI funcion acts similar to an Update funcion, but OnGUI
gets called more than once, for rendering and handling GUI events,
meaning that OnGUI implementaion might be called several imes
per frame (one call per event).
7. In the OnGUI funcion, we will assign our customSkin , create a window menu,
make it draggable, and check to make sure that the window is always on the screen;
so add this code after the Update funcion:
//All GUI Class will create in this function
public function OnGUI () : void {
GUI.skin = customSkin; //Assign our MenuSkin to the Gui Skin
if (b_openMenu) { //If open menu == true create a menu window
r_window = GUI.Window (0, r_window, DoMyWindow, ""); //create
a new window by the size of rect
//This whole code is to make sure that our window can't be
dragged outside of the screen area
//////////////////////////////////////////////////////////////
/////////////////
r_window.x = Mathf.Clamp(r_window.x, 0.0, Screen.width - r_
window.width);
r_window.y = Mathf.Clamp(r_window.y, 0.0, Screen.height - r_
window.height); //////////////////////////////////////////////
//////////////////////////////////
}
}
//Our window function operates here
private function DoMyWindow (windowID : int) : void {
//We create tab button here.
in_toolbar = GUI.Toolbar (r_tabButton, in_toolbar, s_toolbars,
GUI.skin.GetStyle("Tab Button"));
switch (in_toolbar) {
case 0 : //Status
//Create a status page
break;
case 1 : //Items
//Create an item page
break;
case 2 : //Equip
//Create an equipment page
break;
 
Search WWH ::




Custom Search