Skip to content

Commit c5251ce

Browse files
author
Tim Gerken
committed
Added an option to use sharedMaterial when fading.
1 parent 0387d21 commit c5251ce

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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)