Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
boone188's avatar
boone188
Honored Guest
12 years ago

Unity GUI Package + Example

Getting GUIs working for VR in Unity seems to be a big cause of pain for people getting started. It is definitely something that needs to be simplified, so I went ahead and created a package to do just that. VRGUI should have you making GUIs in no time. Here is how it works:

1. First you need to import the VRGUI package into your project.
2. Now you need to create a script for your GUI that extends from VRGUI and implements the OnVRGUI method:

public class ExampleMenu : VRGUI
{
public override void OnVRGUI()
{
GUILayout.BeginArea(new Rect(0f, 0f, Screen.width, Screen.height));
if (GUILayout.Button("Click Me!"))
{
doSomething();
}
GUILayout.EndArea();
}
}

3. Now you need to add this script as a component of your player:
- You can attach it to the camera and it will follow your eyes, or
- You can attach it to your player controller and it will follow your player
4. You can choose to have the GUI displayed on a flat surface or a curved surface (the "Use Curved Surface" field)
5. You can choose where to position the GUI (the "GUI Position" field)
6. You can choose how much to scale the GUI (the "GUI Size" field)
7. You can choose to let the GUI accept mouse and keyboard events (the "Accept Mouse" field)

I have included an example project that shows a very simple implementation of a menu and a HUD. Hope this helps!

47 Replies

Replies have been turned off for this discussion