Skip to content

Commit 03472ab

Browse files
authored
Merge pull request #440 from aalmada/SetGlobalListener
Unregister global listeners on destroy
2 parents bd742a6 + f37b0d9 commit 03472ab

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Assets/HoloToolkit-Examples/SharingWithUNET/Scripts/PlayerController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ private void Start()
7878
transform.SetParent(sharedWorldAnchorTransform);
7979
}
8080

81+
private void OnDestroy()
82+
{
83+
if (isLocalPlayer)
84+
{
85+
InputManager.Instance.RemoveGlobalListener(gameObject);
86+
}
87+
}
88+
8189
private void Update()
8290
{
8391
// If we aren't the local player, we just need to make sure that the position of this object is set properly

Assets/HoloToolkit-Examples/SpatialUnderstanding/SpatialUnderstanding-FeatureOverview/Scripts/AppState.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ private void Start()
198198
InputManager.Instance.AddGlobalListener(gameObject);
199199
}
200200

201+
protected override void OnDestroy()
202+
{
203+
InputManager.Instance.RemoveGlobalListener(gameObject);
204+
}
205+
201206
private void Update_DebugDisplay(float deltaTime)
202207
{
203208
// Basic checks

Assets/HoloToolkit/Input/Scripts/SetGlobalListener.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@ private void Start()
1414
{
1515
InputManager.Instance.AddGlobalListener(gameObject);
1616
}
17+
18+
private void OnDestroy()
19+
{
20+
InputManager.Instance.RemoveGlobalListener(gameObject);
21+
}
1722
}
1823
}

0 commit comments

Comments
 (0)