UI Raycast Camera can be destroyed at runtime with a multi-scene-setup
Describe the bug
There is no recovery from the UIRaycastCamera being destroyed at runtime. Due to the camera being spawned within the active scene, it doesn't guarantee the camera exists within the same scene as the core MRTK objects.
To reproduce
Steps to reproduce the behavior:
- Run Unity with an empty scene.
- Load a scene [Additive] with the core MRTK objects within it.
- The UIRaycastCamera is instantiated into the active scene (the empty scene).
- Unload the active scene (the empty one).
- MixedRealityInputModule throws exceptions because the camera is destroyed.
Expected behavior
The UIRaycastCamera should persist by either using DontDestroyOnLoad or being moved to the scene where the core MRTK objects exist.
Your setup (please complete the following information)
- Unity Version 2019.3.4f1
- MRTK Version 2.4.0
Target platform (please complete the following information)
- HoloLens 2
@Railboy I think that this is part of what the scene system that you added was intended to solve
I seem to hit this now when I have upgraded to MRTK 2.4.0 (from 2.3.0, following the upgrade guide). I use the LoadAdditiveScene script from one of the examples (think it was included in one of the eye tracking exmaples). Directly on load for the new scene the Camera seems to be destroyed and it's spitting out errors. Attached a file containing the three repeating errors' stack traces separated by some newlines, they can maybe help.
This seemed to solve itself by removing the MixedRealityToolkit and camera parent and reapply it with the MRTK tool Add to scene and configure...
I've had an issue like this when using additive scenes in the editor with the Scene Manager System. You have to select DefaultManagerScene as the active scene. The problem is UIRaycastCamera always instantiates in the active scene.
This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.
We appreciate your feedback and thank you for reporting this issue.
Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.
Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.
Please note that MRTK3 was released in August 2023. It features an all-new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visit https://www.mixedrealitytoolkit.org.
Thank you for your continued support of the Mixed Reality Toolkit!