Game Development Reference
In-Depth Information
Step 46: Create a new GUITexture, name it Crosshairs. Use the Crosshairs
texture from the project panel as the texture for the GUITexture. Leave the
Transform values as is, but change the Pixel Inset values to X = -16 , Y = -16 ,
Width = 32 , Height = 32 .
Why?
Yeah, you're right. We made one of these back in the Hallway. We're going
to delete that one eventually. The idea is that now that we've determined
the GUI elements for the game, we'll assemble them all there and be able
to use them again and again as a prefab.
Step 47: Create a new empty GameObject (GameObject>Create Empty).
Name it GUIElements . Make sure its Transform Position and Rotation
values are all 0 .
Step 48: Make Crosshairs, EntryWayTextHints, InventoryButton_Tab (with
its children), and InventoryPrompt all children of GUIElements ( Figure 16.4 ).
Warnings and Pitfalls
It's VERY important that
the Transform values for
Position and Rotation are 0.
If they are not, when they
become the parents of
the GUI elements, all sorts
of things will go awry as
the children will need to
change their Position and
Rotation to account for
their parent.
Figure 16.4 All the GUIElements grouped under one GameObject, ready to be made a prefab.
Step 49: Rename EntryWayTextHints to just GUITextHints .
Step 50: Open the script EntryWayTextTriggerScript.
Step 51: Change the guiTextObject = GameObject.Find line to read:
function Awake(){
guiTextObject = GameObject.Find("GUITextHints");
}
Why?
We renamed an object. Since we were finding that object via a GameObject
.Find command, we've got to make sure and change the script.
Step 52: Save and return to Unity. Fix any syntax problems.
Create a GUIElements Prefab
Step 53: In the Project panel, choose Create>Prefab. Rename the new
prefab GUIElements . This can be placed within a folder if you are
organizing your prefabs into one place, or just floating within the project.
Step 54: Drag the GUIElements from the Hierarchy to the new GUIElements
prefab in the Project panel.
Search WWH ::




Custom Search