Skip to content

Commit 290cec0

Browse files
author
Tim Gerken
committed
Mark SingleInstance.OnDestroy() as virtual so extending scripts
have the opportunity to do their own cleanup when Unity calls this function on their behalf.
1 parent 57a1891 commit 290cec0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Assets/HoloToolkit/Utilities/Scripts/SingleInstance.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ public static T Instance
3232
}
3333
}
3434

35-
protected void OnDestroy()
35+
/// <summary>
36+
/// Called by Unity when destroying a MonoBehaviour. Scripts that extend
37+
/// SingleInstance should be sure to call base.OnDestroy() to ensure the
38+
/// underlying static _Instance reference is properly cleaned up.
39+
/// </summary>
40+
protected virtual void OnDestroy()
3641
{
3742
_Instance = null;
3843
}

0 commit comments

Comments
 (0)