The Product College early application deadline is Oct 31 - Apply Now

Making The Menu

Making The Menu

October 9, 2010
Expand

Project: Learn How to Build Drift

Let’s add a Menu Scene that we’ll go back to when we win.

Create a new Scene in the Scenes folder named Main and remove the Skybox.

The Main Scene in the Project Panel

Drag a SteamVR_Camera component onto Main Camera. Be sure to position Main Camera at (0,0,0).

The camera set up to be a VR camera

Now add a Canvas to the Scene. Set its Render Mode to World Space, Scale it to 0.1 in all dimensions, and set its position to (0,0,100).

A world space canvas

Now add some Text as a child to it and write something like Squeeze Grip to Begin. Format it as you see fit.

Instructions on the menu

Now you should see some text floating in front of you.

The text should float in front of you

To make the effect a little nicer, we made the Camera’s Background color gray and the text white.

Starting the game

Now implement functionality to switch to the Play scene when you squeeze the controller.

Set up the scene to switch when you squeeze the grip

Don’t forget to add your Scenes to the Build Settings! (Drag it to File > Build Settings)

We created a component called MenuController, on a MenuController GameObject, with the following implementation:

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

[RequireComponent(typeof(SteamVR_TrackedController))]
public class MenuController : MonoBehaviour
{
    private SteamVR_TrackedController controller;

    // Use this for initialization
    void Start()
    {
        Initialize();
    }

    void Reset()
    {
        Initialize();
    }

    // Update is called once per frame
    void Update()
    {
        if (controller.gripped)
        {
            SceneManager.LoadScene("Play");
        }
    }

    void Initialize()
    {
        controller = GetComponent<SteamVR_TrackedController>();
        int rightIndex = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost);
        controller.SetDeviceIndex(rightIndex);
    }
}

Back to the menu

Now add logic to switch back to Main when you beat the level.

Switch back when you beat the game!

We replaced our log statement with this:

SceneManager.LoadScene("Main");
return;

Now you have a feature-complete one-level game!

Go ahead and make it more interesting than a hallway by changing the path and/or adding some obstacles.

We added trees to make our game pretty!

We downloaded a package off the Asset Store with low poly trees and put them all over with the Default-Diffuse material! We also imported the Standard Assets Effects package and applied some Bloom to the Main Camera (eye), because Bloom looks oh so pretty. We also thought our lights would look prettier a little brighter and played around with our Particle System to make it more subtle (it’s now a cone and has overall lower opacity) ;)

As a final touch, we added the title, Draft, to the Main Menu, as some pulsing Text.

Our menu is so pretty :3

Be sure to save your Scenes and save your project!

Feel free to enjoy this version on its own for a little. Go on to the next part to learn how to add a level structure!

Feedback

If you have feedback on this tutorial or find any mistakes, please open issues on the GitHub Repository or comment below.

Summer academy

An iOS Development Summer Course

Design, code and launch your own app. Locations across the USA and Asia

Find your location

Product College

A computer science college

Graduate into a successful career as a founder or software engineer.

Learn more