Virtual Reality Cameras

From PowerUI
Revision as of 14:55, 13 January 2017 by 151.229.186.156 (talk) (Created page with "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 C...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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;

Some point before you setup your UI. Usually dropping it in an Awake works great. (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.