Game Development Reference
In-Depth Information
Step 15: Create biography data panel. Do this by creating a GUITexture,
using DataPanel_Biography (in 2D Assets) to define the Texture. Center it
on the screen (Transform Position X = 0.5 and Y = 0.5 ). Set the size to
512×512(PixelInsetWidth= 512 , Height = 512 ) and offset Y to taste (Pixel
Inset Y = -256 on my screen). Rename to DataPanel_Biography .
Step 16: Repeatstep15andcreateadatapanel DataPanel_Mission .
You could also just copy/paste DataPanel_Biography, swap the Texture (use
DataPanel_Mission from the 2D Assets), and rename to DataPanel_Mission .
Why?
Note that both of the DataPanels will be active and right on top of each
other. Don't worry, we'll hide them in just a bit.
Step 17: Change the color of each of the buttons to a dark gray. Do this
by selected each button in the Hierarchy panel. Then in the Inspector
panel, click the Color swatch. Pick a darker gray (I used RGB all equal
to50).
Why?
The idea here is to make the buttons highlight white when the player
mouses over them. Although we could define this programmatically, we
can also manually start with the buttons unhighlighted.
Scripting the GUI
Step 18: Nest the Console in your interface. First make the Console visible
with Window>Console. Grab the console tab and drag it over the Unity
interface. Unity will attempt to snap and dock it into place. When the
mouse is released, the console will stay there.
Step 19: Create a Scripts folder to hold the script assets. In the Projects
panel, be sure nothing is selected (click some empty gray space if need
be), and choose Create>Folder. Rename the folder Scripts .
Step 20: Create a new script in the Scripts folder. To do this, select
the Scripts folder and choose Create>JavaScript. This will create a
NewBehaviourScript that is already inside the Scripts folder.
Step 21: Rename the NewBehaviourScript to OpenSceneButtonsScript .
Step 22: Open the script by double-clicking OpenSceneButtonsScript.
This will open either Unitron or UniSciTE (or another script editor if you've
defined it to do so).
Step 23: Delete all the contents of the script (highlight it all and delete).
Why?
By default these new scripts contain the built-in function, function Update()
and the {} that sandwich the function Unity is sure you're going to write.
In this case, we are going to write a function that doesn't fire every frame
Search WWH ::




Custom Search