Overview
UIVirtualScreen works like, well, a virtual screen in your game world, onto which you can render a texture of a UI elsewhere in your scene. (Think of the computer screens in Doom 3, for example.) Basically, all you have to do is map a render texture onto whatever object you want, and then if you've added a UIVirtualScreen component to it, it acts like a virtual screen in your game. It takes care of relaying input properly to the controls that sit in front of your camera that is rendering to texture.
What it's good for * A virtual book, complete with turning, bendy pages. * Doom 3-like in-game computer interfaces. (This can be better than the approach in the original hangar FPS demo since you don't have to use managed sprites, etc, to make sure control depth-sorting doesn't mess up ordering when using a perspective camera. Using this method, you can set up an orthographic camera to render your GUI, and then map that onto an object in 3D space and view it without issue using a perspective camera.)
How to use it * Setup a UI somewhere in your scene and point a camera at it that renders to texture. We will call this camera the "screen camera". NOTE: This camera should not be added to the UIManager's "UI Cameras" array as it is handled by the virtual screen instead. * Add an object in your scene that uses this render texture. This could be a Cube, a SimpleSprite, or any arbitrary object. We will call this the "screen object". * Add the virtual screen component to your screen object (you'll find the Virtual Screen item under Components->EZ GUI->Controls). * Make sure your object has a mesh collider on it. It has to be a mesh collider, or else it won't receive the info it needs to relay the input. * Then, drag your screen camera onto the "Screen Camera" field of the UIVirtualScreen inspector. * If you have any scroll bars or scroll lists, you will probably want to make sure the "Process Pointer Info" box is checked, and then drag the common parent object of all your controls you're rendering to texture onto the "Control Parent" field. If you don't have a common parent, group them together under one. They don't have to be the immediate children of the same parent. Just some parent object somewhere up the chain that they all have in common. Now when you mouse over/touch anywhere on the 3D object that is using the render texture (and of course has the virtual screen component on it), the UI being rendered will respond accordingly. |
Class |
Properties
|