Game Development Reference
In-Depth Information
GUI.DrawTexture(HERO_RECT, heroTexture);
}
// C# user:
void DoMyWindow (int windowID ) {
_currentTool = (TAB) GUI.Toolbar (TAB_BTN_RECT,
(int)_currentTool, TOOLBARS, GUI.skin.GetStyle("Tab
Button"));
switch (_currentTool) {
case TAB.STATUS : //Status
StatusWindow();
break;
}
GUI.DrawTexture(HERO_RECT, heroTexture);
}
Tip
switch-case : To make the code run efficiently, why don't we use the if-
else statement? Well, the switch-case statement makes the code easier to
read, and also, this performs faster because the complier doesn't need to compare
the value of each state before jumping to the next one, which might be the case
when we use the if-else statement. The last state might take more time to ac-
cess because of waiting for the previous state to finish.
Basically, for the switch-case statement, all the items will get access at the
same time. In our case, we will add another two states later in the next step. Even
though there is a slight boost in our code, it recommended to use the switch-
case if we have more than two states.
We can go back to Unity and click on Play to see the result; we will see that all
the attributes are shown in the window. However, we will still see that there is no
text shown under the Weapon , Armor , and Accessory sections.
Search WWH ::




Custom Search