Game Development Reference
In-Depth Information
Eventually, this is where you will end up if programming is your path of
choice. The problem (for beginners) with this methodology is that it can be
fairly opaque and abstract to understand how things are working. It is why in
Incursion we have focused on hanging scripts off of objects. However, with
the complexity of the AC_ToolFunctionalityScript, you can see the start of
fewer scripts controlling more things.
We've looked a little bit at scripts talking to each other already. But understanding
inner-script communication is a critical part of an effective project, and central to
the state engine concept. It also happens to be one of the most frequently asked
questions on the forums.
To further illustrate this, we'll create another script that controls our
inventory system. This inventory system will communicate with the tool
functionality script (AC_ToolFunctionalityScript) to let it know which tool
to fire up.
To do this, we'll return to where we started and create a new inner-game GUI
system.
Tutorial 16.1: Setting Up Inventory GUI
and Script
Step 1: Open Scene-EntryWay if it is not already open.
Step 2: Create GUI layout with GUITextures. Create four GUITexture
objects (GameObject>Create Other>GUI Texture). Name them
InventoryButton _ EMP , InventoryButton_Flashlight,
InventoryButton_Pistol and InventoryButton_Tab.
Step 3: Populate the GUITextures with textures. In the 2D Assets folder
(from the 2DAssets Unity Package imported earlier) are a bunch of texture
files that start with ButtonInventory. Use ButtonInventory-EMP for the
InventoryButton_EMP GUITexture, ButtonInventory-Flashlight for the
InventoryButton_Flashlight, Inventory-Pistol for the InventoryButton_
Pistol GUITexture, and Inventory-Tab-Vert for the InventoryButton_Tab
GUITexture.
Step 4: Size the GUITextures. For all but the Inventory_Tab GUITexture,
change the Pixel Inset Width and Height to 128 . For the InventoryButton_Tab
GUITexture, change the Pixel Inset Width to 32 and the Height to 128 .
Step 5: Arrange all four GUITextures to be aligned in the top-left
corner of the game screen. Do this by selecting each and in the
Inspector, under the Transform, enter Position X = 0 and Position
Y = 1 . Since GUITextures are set up from the bottom-left corner of the
texture image, this will make them all disappear. We'll fix that in the
next step.
Step 6: Offset all -128 in Y. Select each, and in the Inspector, under the
GUITexture component, change the Pixel Inset Y to -128 . This will show all
the GUITextures, but they'll be on top of each other.
Search WWH ::




Custom Search