Virtual Reality Cameras

From PowerUI
Revision as of 15:41, 3 February 2017 by 151.229.186.156 (talk)
Jump to: navigation, search

In virtual reality, it's common to see the middle of the screen being used as the input pointer. Think Minecraft and similar. Here's how you set that up in PowerUI using the CameraPointer class.

First, you'll probably want to turn off the mouse pointer (It's used on desktops only). It's the input pointer which is controlled by the mouse. To disable it, do this:

PowerUI.Input.CreateSystemMouse=false;

You would usually want the above in an Awake method. (Specifically, it must happen before UI.Start() is called which happens inside the PowerUIManager's Start method).

Next, you'll then want to create the camera pointer itself. That's like this:

// Create a camera pointer that sits in the middle of the screen (50%,50%):
CameraPointer pointer=new CameraPointer(Camera.main,0.5f,0.5f);

// Add it now:
pointer.Add();

And that's all it takes! Whenever your camera is transformed (i.e. rotated or moved around), the pointer automatically updates itself. Note that the UI's used would almost always be one or more WorldUI's.