Closed genereddick closed 5 years ago
No steps to repro?
Updated
TeleportMarker is instantiated in the MixedRealityTeleport script Start function.
private void Start()
{
...
if (teleportMarker != null)
{
teleportMarker = Instantiate(teleportMarker);
teleportMarker.SetActive(false);
animationController = teleportMarker.GetComponentInChildren<Animator>();
if (animationController != null)
{
animationController.StopPlayback();
}
}
}
Because this script is on the MixedRealityCameraParent which has DontDestroyOnLoad, the Start function is only called on the first scene load. The teleportMarket is created in the first scene, but doesn't survive the scene load and it doesn't look like there is a mechanism to reinstantiate it in new scenes.
Using Unity 2017.2.0p1 - MRTP4 64bit + HoloToolkit-Unity-v1.2017.2.0
I have another issue when changing scene, controllers disappear. Throws exception on line 496 of InputManager.cs, sourceStateEventData is null on next scene.
NullReferenceException: Object reference not set to an instance of an object
HoloToolkit.Unity.InputModule.InputManager.RaiseSourceDetected (IInputSource source, UInt32 sourceId, System.Object[] tags) (at Assets/HoloToolkit/Input/Scripts/Utilities/Managers/InputManager.cs:496)
HoloToolkit.Unity.InputModule.InteractionInputSource.OnEnable () (at Assets/HoloToolkit/Input/Scripts/InputSources/InteractionInputSource.cs:189)
@cvasquez-github that bug was fixed and is a separate issue.
Great to know @StephenHodgson , thanks for letting me now that was fixed. Where can I get the fix for that bug? Thanks!
Update: adding InputManager (100) and InteractionInputSource (200) to the Script Execution Order prevents the issue.
Latest master branch. Will be included in a release soon.
Is there a workaround for the dying Teleport marker?
Add don't destroy on load to it.
Actually it is not enough to just add don't destroy on load. Property assignments don't necessarily survive scene loading. In this case, even though the Teleport Marker now survives the scene load, the value of teleportMarker does not:
private GameObject teleportMarker;
Which is assigned in the MixedRealityTeleport.cs script Start function:
if (teleportMarker != null)
{
teleportMarker = Instantiate(teleportMarker);
When you load a new scene that value is now null as are some other properties. I'm still not totally clear on which values survive scene loads -- static values on all objects, behavior of properties on objects with dontdestroyonload, nested gameobjects all seem to have different rules. -- but I expect this issue and others related to multi-scene projects are going to continue to cause problems unless addressed across all singletons.
So here, in addition to adding DontDestroyOnLoad to the the TeleportMarker.prefab, you also need to add some code to reset the reference when the new scene is loaded. This applies to animationController as well.
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:
private void Awake() {
SceneManager.sceneLoaded += SceneLoaded;
}
void SceneLoaded(Scene scene, LoadSceneMode mode) {
if (teleportMarker != null) {
teleportMarker = Instantiate(teleportMarker, this.transform);
teleportMarker.SetActive(false);
animationController = teleportMarker.GetComponentInChildren<Animator>();
if (animationController != null) {
animationController.StopPlayback();
}
}
}
I'm in favor of either 1 or 2.
I believe #1 requires only the following change in MixedRealityTeleport.cs, line 87
teleportMarker = Instantiate(teleportMarker, this.transform);
I'll test it out and see if I find any issues related to being a child of the MixedRealityCameraParent.
Found a quick fix for this. I put this in MixedRealityTeleport.cs:
public void LoadMarker()
{
teleportMarker = Resources.Load("TeleportMarker") as GameObject;
animationController = teleportMarker.GetComponent
and then I have a small script on an empty object in the scene that is being switched to with this:
private void Awake()
{
GameObject.Find("MixedRealityCameraParent").GetComponent
I also set the script execution order so this will be earlier than the others, but i'm not sure if this is necessary or not.
I'm seeing an issue when I run the SceneLauncher scene, and load a few scenes... the controller model seems to retain its original location prior to the scene reload, and the turn (left/right) on the joystick just cause a black plane to appear, without changing my view... is this all related to the same issue, and is the fix above valid to fix that?
example at : https://www.youtube.com/watch?v=hM5Ur_-4kiU
Thanks...
Closing issues older than 180 days. If this is still an issue, please reactivate with recent information.
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
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