MixedRealityToolkit-Unity: Teleport Marker doesn't survive scene change
Overview
Running a project with multiple scenes, when a new scene is loaded the Mixed Reality Teleport Script loses its reference to the initial instance of Teleport Marker instantiated in the first scene. The Teleport Manager doesn’t survive the scene load and a new one isn’t created in the new scene.
Expected Behavior
No errors, can select using Controller
Actual Behavior
Three errors, xbox controller no longer functions, can’t select or interact
MissingReferenceException: The variable teleportMarker of MixedRealityTeleport doesn't exist anymore.
You probably need to reassign the teleportMarker variable of the 'MixedRealityTeleport' script in the inspector.
HoloToolkit.Unity.InputModule.MixedRealityTeleport.EnableMarker () (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs:285)
HoloToolkit.Unity.InputModule.MixedRealityTeleport.StartTeleport () (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs:214)
HoloToolkit.Unity.InputModule.MixedRealityTeleport.HandleGamepad () (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs:124)
HoloToolkit.Unity.InputModule.MixedRealityTeleport.Update () (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs:103)
MissingReferenceException: The object of type 'Animator' 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.
HoloToolkit.Unity.InputModule.MixedRealityTeleport.PositionMarker () (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs:316)
HoloToolkit.Unity.InputModule.MixedRealityTeleport.Update () (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs:109)
MissingReferenceException: The variable teleportMarker of MixedRealityTeleport doesn't exist anymore.
You probably need to reassign the teleportMarker variable of the 'MixedRealityTeleport' script in the inspector.
HoloToolkit.Unity.InputModule.MixedRealityTeleport.DisableMarker () (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs:298)
HoloToolkit.Unity.InputModule.MixedRealityTeleport.FinishTeleport () (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs:236)
HoloToolkit.Unity.InputModule.MixedRealityTeleport.HandleGamepad () (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs:129)
HoloToolkit.Unity.InputModule.MixedRealityTeleport.Update () (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs:103)
Steps to reproduce
Create a project with two scenes. Load initial scene then load second scene. Use xbox left thumbstick.
You can see that the Mixed Reality Teleport Script on MixedRealityCameraParent in the Unity Editor is null.
Unity Editor Version
2017.2.op1-MRTP4
Mixed Reality Toolkit Release Version
master
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (6 by maintainers)
Three options:
Instantiate TeleportMarker as a child of MixedRealityCameraParent. Then doesn’t require DontDestroyOnLoad, but not sure of any implications of tying the position and rotation of the TeleportMaker to the camera.
Make TeleportMarker a Singleton. Will both survive the scene load and will retain the reference in MixedRealityTeleport.
Add some code to handle rewiring the object in MixedRealityTeleport. This could be done either through re Instantiating the TeleportMarker (in which case it doesn’t need DontDestroyOnLoad), or just use Find to grab it and reassociate it (if TeleportMaker has DontDestroyOnLoad).
In MixedRealityTeleport.cs: