This asset allow viewing and interacting with Windows Desktop (mainly Unity Editor) within VR.
Useful for example for tuning variables in inspector without need to leave the VR headset.
All source-code (C# Unity and C++ DLL) is released on GitHub under a LGPL licence: GitHub - Clodo76/vr-desktop-mirror: Windows Desktop Mirror - DLL and Unity Asset
Requirements
- HTC Vive or Oculus Rift CV1/DK2
- Windows 64 bit
- SteamVR asset if used with HTC Vive
How to
- Install this package: Download (41 KB!) - v1.0
If you have a compilation error about missing SteamVR_Controller, comment the first line
#define VDM_SteamVR
This will remove the support of HTC Vive.
-
Drag āVR Desktop Mirror > Prefabs > VR Desktop Mirrorā in project tree.
-
Start PlayMode, pick your VR headset.
With Keyboard / Mouse / Oculus Rift:
- Press the left control to show the desktop. Quick press to hide. Hold press to move. During hold press, use the scroll wheel to adjust distance.
- Press the left alt to switch to zoom mode (for better aiming). Use the scroll wheel to adjust the zoom distance.
- Important*: If you interact with Unity Editor UI, the detection of keyboard for show/zoom donāt work. Re-give the focus to the Game View window.
Note also that it reflect the mouse event in the REAL screen position, NOT the mouse over the plane/texture.
With HTC Vive:
- Click the Grip button on any controller. It will show the desktop.
- Point with the controller the desktop and retain press the Grip for positioning.
- Point and short-click the Grip to hide.
- Interact with the desktop with any controllers.
- Trigger act as mouse left click.
- Thumbpad act as mouse left or right click, depend on the side pressed.
Properties of the asset have tooltip with specific documentation.
The BIG issue
Some functionality of Unity (for example, menu and context menu) pause the playback, and so the VR environment. I consider this issue an Unity bug, because occur even if āPlay in backgroundā is enabled.
I opened a topic in the Editor forum, and i also fill a bugreport.
Until the bug is fixed, the asset detect and close any menu and context-menu to avoid the VR environment lock. This can be disabled by unchecking the property āHackUnityBugā.
The following itās a list (not exaustive) of action not allowed:
- Unity Editor Menu (for example File, Window etc).
- Any Context Menu (for example right click on a gameobject).
- Any enum property in inspector (that are managed with a context menu).
- Removing a component (that are managed with a context menu; Adding a component work).
- etc.
A little issue
Unity for a Input.GetKeyDown(KeyCode.X) return always false also if the X key is pressed, but Game View in Play Mode donāt have the focus. This issue donāt occur with HTC Vive buttons. If anyone know how to resolve this, please write a post. Thanks.
Faq
Q- What if i use āDragā or āTouchpad clickā in my game?
A- To avoid collisions, in your script check the bool āVdmDesktopManager.ActionInThisFrameā, and skip your behiavour if is True (Input accepted for interaction with the desktop).
Q- Future of this asset?
A- There are a lot of possible improvements:
- Support of multiple monitors
- More buttons configurations preset
- Simulation of mouse wheel or center mouse click
- Virtual keyboard
But honestly the Unity bug described above itās serious, i hope that someone can help me to point out to Unity team the issue, otherwise it seem useless to improve this project.
Thanks for any feedback.