|
1 | | -// Copyright (c) Microsoft Corporation. All rights reserved. |
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
2 | 2 | // Licensed under the MIT License. See LICENSE in the project root for license information. |
3 | 3 |
|
4 | 4 | using Microsoft.MixedReality.Toolkit.Core.Definitions; |
@@ -364,8 +364,25 @@ public Transform MixedRealityPlayspace |
364 | 364 | } |
365 | 365 | else |
366 | 366 | { |
367 | | - mixedRealityPlayspace = new GameObject("MixedRealityPlayspace").transform; |
368 | | - CameraCache.Main.transform.SetParent(mixedRealityPlayspace); |
| 367 | + string MixedRealityPlayspaceName = "MixedRealityPlayspace"; |
| 368 | + if (CameraCache.Main.transform.parent == null) |
| 369 | + { |
| 370 | + mixedRealityPlayspace = new GameObject(MixedRealityPlayspaceName).transform; |
| 371 | + CameraCache.Main.transform.SetParent(mixedRealityPlayspace); |
| 372 | + } |
| 373 | + else |
| 374 | + { |
| 375 | + if (CameraCache.Main.transform.parent.name != MixedRealityPlayspaceName) |
| 376 | + { |
| 377 | + // Since the scene is set up with a different camera parent, its likely |
| 378 | + // that there's an expectation that that parent is going to be used for |
| 379 | + // something else. We print a warning to call out the fact that we're |
| 380 | + // co-opting this object for use with teleporting and such, since that |
| 381 | + // might cause conflicts with the parent's intended purpose. |
| 382 | + Debug.LogWarning("The Mixed Reality Manager expected the camera's parent to be named " + MixedRealityPlayspaceName + ". The existing parent will be renamed and used instead."); |
| 383 | + CameraCache.Main.transform.parent.name = MixedRealityPlayspaceName; // If we rename it, we make it clearer that why it's being teleported around at runtime. |
| 384 | + } |
| 385 | + } |
369 | 386 |
|
370 | 387 | // It's very important that the MixedRealityPlayspace align with the tracked space, |
371 | 388 | // otherwise reality-locked things like playspace boundaries won't be aligned properly. |
|
0 commit comments