Pointer broken on scene switch for WMR
Environment
- VRTK cloned from Github
- Commit 97cc00b4f0183c23574374d5635eb0baeefd7a78 (latest as of 4/27)
- Unity v2017.2.2f1
- WMR Samsung Odyssey
- VRTK-Windows-MR-Extension release 3.3.0 (.unitypackage from Releases)
Steps to reproduce
- Clone master branch of VRTK
- Import VRTK-Windows-MR-Extension from Releases
- Open VRTK > Examples > VRTK_SDKManager_Constructor
- Follow all instructions in Getting started and WMR SDK setup
Scenario One
- Open VRTK > Examples > [001 - Interactions] ControllerEvents
- Enter Play mode
- Switch scenes (press spacebar)
Scenario Two
- Open VRTK > Examples > [002 - Pointers] StraightPointer
- Enter Play mode
- Switch scenes (press spacebar)
Scenario Three
- Open VRTK > Examples > [003 - Pointers] BezierPointer
- Enter Play mode
- Switch scenes (press spacebar)
Expected behavior
Scenario One Scene 001 shouldn't have any Pointer functionality. When you switch to scene 002, you should be able to use the Pointer by touching the touchpad.
Scenario Two You should be able to use the Pointer in Scene 002 by touching the touchpad. When you switch to scene 003, you should be able to use the Pointer by touching the touchpad.
Scenario Three You should be able to use the Pointer in Scene 003 by touching the touchpad. When you switch to scene 004, you should be able to use the Pointer by touching the touchpad.
Current behavior
Scenario One Scene 001 is fine. The Pointer doess not appear in scene 002. No errors appear.
Scenario Two The Pointer appears and operates correctly in scene 002, but throws an error in scene 003:
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
VRTK.VRTK_BasePointerRenderer.GetOrigin (Boolean smoothed) (at Assets/VRTK/Source/Scripts/Pointers/PointerRenderers/VRTK_BasePointerRenderer.cs:402)
VRTK.VRTK_StraightPointerRenderer.CastRayForward () (at Assets/VRTK/Source/Scripts/Pointers/PointerRenderers/VRTK_StraightPointerRenderer.cs:200)
VRTK.VRTK_StraightPointerRenderer.UpdateRenderer () (at Assets/VRTK/Source/Scripts/Pointers/PointerRenderers/VRTK_StraightPointerRenderer.cs:62)
VRTK.VRTK_Pointer.HandleEnabledPointer () (at Assets/VRTK/Source/Scripts/Pointers/VRTK_Pointer.cs:375)
VRTK.VRTK_Pointer.Update () (at Assets/VRTK/Source/Scripts/Pointers/VRTK_Pointer.cs:337)
Scenario Three The Pointer appears and operates correctly in scene 003, but throws an error in scene 004:
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
VRTK.VRTK_BasePointerRenderer.GetOrigin (Boolean smoothed) (at Assets/VRTK/Source/Scripts/Pointers/PointerRenderers/VRTK_BasePointerRenderer.cs:402)
VRTK.VRTK_BezierPointerRenderer.ProjectForwardBeam () (at Assets/VRTK/Source/Scripts/Pointers/PointerRenderers/VRTK_BezierPointerRenderer.cs:209)
VRTK.VRTK_BezierPointerRenderer.UpdateRenderer () (at Assets/VRTK/Source/Scripts/Pointers/PointerRenderers/VRTK_BezierPointerRenderer.cs:79)
VRTK.VRTK_Pointer.HandleEnabledPointer () (at Assets/VRTK/Source/Scripts/Pointers/VRTK_Pointer.cs:375)
VRTK.VRTK_Pointer.Update () (at Assets/VRTK/Source/Scripts/Pointers/VRTK_Pointer.cs:337)
Bonus Info:
Same exact setup was tested with SteamVR + Vive as well as SteamVR + Odyssey (WMR) with NO issues (behaved as expected).
Side note: I noticed that in PR #1745 (feat(SDK): add native Unity Windows Mixed Reality support) @simondarksidej said:
All went' smoothly with all the ducks in a row (as it were), could even switch scenes (once I learned how to)
And I'm not sure if this meant he actually tested the intended functionality in each scene or not.
I'll retest in the latest. But was all working fine last time I tested (both in Steam VR and in native WMR)
Ok, done some re-testing today and something has definitely changed. I've now tested with 2017.4.1 & 2018.1.0 in both .NET and IL2CPP
When I initially tested the WMR PR, everything worked fine. Did exactly the same as the above replication steps and then used Space to navigate between scenes and everything worked.
Now however, when you change scenes, the controllers stop responding for buttons.
For example:
A) if you start on Example 1, all buttons work as expected B) if you then use the scene switcher to go to Example 2, controller buttons stop C) If you stop and load Example 2 direct then everything works as expected D) if you then use space to switch to Example 3, they stop again. E) If as before you load Example 3 on start, it works.
So my question is @thestonefox, has something changed on the scene switcher that might cause this? This ONLY occurs when you switch scenes. (same error observed as noted above, but yes, only for Examples 2 onwards)
I'm testing with a compiled build, just to check if this is a new Editor "feature" or something else.
And the prize for the thing that creates the most bugs in software goes to.... Unity. Who could have imagined it, 10 years straight. This is yet another Unity bug, nothing wrong with VRTK.
- Tested current master in Unity 2017.4.1 - fail
- Tested original commit for WMR in Unity 2017.4.1 - fail
- Built for WMR and Run the UWP project naively - WORKS
Tested BOTH by using keyboard and using the Button 2 (menu) + Touchpad + Trigger methods.
If you run it in Unity, the buttons stop working. Built for the platform, no issues.
When I last tested this was with 2017.3.1 (I think), so, yet again something has been enhanced and broken this in the editor.
Hmm, we're running Unity v2017.2.2f1 and seeing the issues.
I'm pretty sure you need a custom version of unity 2017.2 (or do something to make it work properly with wmr) try 2017.3
No, you shouldn't need a custom version. However, it is a Unity bug, not a bug for VRTK as it works in the runtime build.