Search code examples
c#unity-game-enginevirtual-realityhololensmrtk

How do I properly reload a Unity Scene that uses MRTK for the Hololens2?


This is my first project using the Hololens and MRTK for Unity. I want to make a button that restarts the experience for the player when pushed.

I connected a button to a new script with the following code:

SceneManager.LoadScene(SceneManager.GetActiveScene().name);

When the button is pushed the scene seems to reload, but all MRTK/Hololens functionality stops. The hand and eye-tracking are unresponsive, and I am unable to interact with holograms.

I know I can manually make a reset method that moves all the objects in the scene and resets specific scripts, but I'm trying to completely unload and reload as much of the Unity application as possible from a push of a button.

So, how do I properly reload a Unity Scene on the Hololens2? I'm still doing research on this and will update what I find here. I greatly appreciate any assistance here, Thank you!


Solution

  • MRTK actually has a scene system that neatly wraps loading/unloading scenes as well as optional concepts like lighting.

    Take a look at the docs/guides here: https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/SceneSystem/SceneSystemGettingStarted.html