Part 8: Basic User Interface

Christiane Snyder
9/2/2016

We started adding visual indicators meant to communicate with the player. We’ll create a few more in this section to make the experience a bit smoother.

Create a new plane named “StartButton” that will be made into something users can click to begin the experience.

Change your new plane’s property fields to the following values:

 

 

We want to button to say “Start” on it, so create a new text named “StartText” will the following values:

 

 

Add this new text as a child of the StartButton plane.

 

 

Inside of GameManager.cs, add private GameObject variables to represent GvrMain and StartButton. Initialize these references by finding their respective objects in the scene by name.

 

 

Add a StartGame() function to GameManager.cs that will restart the experience:

 

 

StartGame() will reset most variables to the values set in the original Start() function, reset the player location to the middle lane  and spawn a single SpaceShip to begin the game.


Create a new StartButton.cs script that inherits from the IGvrGazeResponder interface and calls the StartGame() function in the GameManager and then deactivates itself when OnGazeTrigger() is called.

 

Attach this new script to your StartButton plane.


Add an Event Trigger as a new component to StartButton and match up the following pointer functions to the gaze functions provided in the attached StartButton.cs script.

 

 

Reactivate the StartButton when the game ends, allowing the player to restart.


Make the following addition in GameManager.cs:

 

 

Add a new 3D text to your scene named “TurnAroundText” with the following properties:

 

 

This text will help guide the player if they are oriented in the wrong direction before the experience actually begins.

Add a reference to this 3D text to  GameManager.cs and initialize it the same way the GameOverText reference was initialized. Once again, set it to inactive in the Start() function, so it's invisible until called upon.

 

 

Now add code in Update() that will reactive TurnAroundText if the game is over or idle and the player is facing away from the StartButton.

 

 

And that’s it! You’ve completed an endless runner for use with Google Cardboard!