Difference between revisions of "Virtual Reality Cameras"

From PowerUI
Jump to: navigation, search
(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...")
 
Line 7: Line 7:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
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)''.
+
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:
 
Next, you'll then want to create the camera pointer itself. That's like this:
Line 19: Line 19:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
And that's all it takes! Whenever your camera is transformed (i.e. rotated or moved around), the pointer automatically updates itself.
+
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.

Revision as of 15:41, 3 February 2017

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.