Unity-Technologies / EditorXR

Author XR in XR
Other
928 stars 166 forks source link

Improve handling of auto-open setting #513

Closed mtschoen-unity closed 5 years ago

mtschoen-unity commented 5 years ago

Purpose of this PR

Handle edge cases related to the new auto-open feature.

Testing status

I have tested this with a Rift in Oculus mode (a.k.a SteamVR isn't running). I have tested the situations described below, as well as generally donning/removing the HMD in various contexts: with Unity focused and in the background, with VR view already open and not open, and having closed VR View with the HMD on vs. off.

Technical risk

Low--only affects the auto-open feature

Comments to reviewers

This changes the following: Do not enable XR or poll for user presence if auto-open is disabled; If the user opens VR View manually, removing the HMD will not close VR View; If the user closes VR View manually after an auto-open, the view will re-open the next time the user is present; Do not attempt to show VR View if Unity is compiling; Do not attempt to show VR view if Unity is not focused, meaning the mouse is not over any Unity window--this was the best way I could find to check if the editor application has focus and will be able to open the view. If XR initialization fails, the preferences window will show a help box informing the user, and provide a retry button to try again when the issue is resolved (i.e. after plugging in the HMD or restarting platform software); Note: This does not update when the HMD is unplugged while Unity is running with auto-open enabled. To resolve that state, the user must uncheck and re-check auto-open.