Skip to content

Commit ed0201a

Browse files
Merge pull request #1122 from timGerken/Dev_Unity_2017.2.0
Add a null-check of TeleportMarker before instantiating the object.
2 parents 9e9f36d + c5251ce commit ed0201a

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ private void Start()
6666
return;
6767
}
6868

69-
teleportMarker = Instantiate(TeleportMarker);
70-
teleportMarker.SetActive(false);
71-
72-
animationController = teleportMarker.GetComponentInChildren<Animator>();
73-
if (animationController != null)
69+
if (TeleportMarker != null)
7470
{
75-
animationController.StopPlayback();
71+
teleportMarker = Instantiate(TeleportMarker);
72+
teleportMarker.SetActive(false);
73+
74+
animationController = teleportMarker.GetComponentInChildren<Animator>();
75+
if (animationController != null)
76+
{
77+
animationController.StopPlayback();
78+
}
7679
}
7780
}
7881

Assets/HoloToolkit/Utilities/Scripts/FadeScript.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace HoloToolkit.Unity
99
{
1010
public class FadeScript : SingleInstance<FadeScript>
1111
{
12+
[Tooltip("If true, the FadeScript will update the shared material. Useful for fading multiple cameras that each render different layers.")]
13+
public bool FadeSharedMaterial = false;
1214
Material fadeMaterial;
1315
Color fadeColor = Color.black;
1416

@@ -46,7 +48,14 @@ void Start()
4648
#endif
4749

4850
currentState = FadeState.idle;
49-
fadeMaterial = GetComponentInChildren<MeshRenderer>().material;
51+
if (FadeSharedMaterial)
52+
{
53+
fadeMaterial = GetComponentInChildren<MeshRenderer>().sharedMaterial;
54+
}
55+
else
56+
{
57+
fadeMaterial = GetComponentInChildren<MeshRenderer>().material;
58+
}
5059
}
5160

5261
void Update()
@@ -90,7 +99,7 @@ void CalculateFade()
9099

91100
protected override void OnDestroy()
92101
{
93-
if (fadeMaterial != null)
102+
if (fadeMaterial != null && !FadeSharedMaterial)
94103
{
95104
Destroy(fadeMaterial);
96105
}

0 commit comments

Comments
 (0)