Skip to content

Commit

Permalink
Fix FollowMeToggle's auto-follow breaking if the component is disabled (
Browse files Browse the repository at this point in the history
#10620)

* Fix FollowMeToggle's auto-follow breaking if the component is ever disabled

`FollowMeToggle` has an `AutoFollowAtDistance` feature which breaks if the `FollowMeToggle` component is ever disabled and re-enabled. This is because the `AutoFollowAtDistance` property setter checks if the `autoFollowDistanceCheck` coroutine is null before starting the coroutine. If the component is disabled, the coroutine will _stop_ but not become null. When the component is re-enabled, the coroutine does not start again because the previous instance is non-null, even though it is no longer running.

This is fixed by simply setting `autoFollowDistanceCheck` to null in `OnDisable()`.

* FollowMeToggle: formatting tweak

Per keveleigh

Co-authored-by: Kurtis <kurtie@microsoft.com>

Co-authored-by: Kurtis <kurtie@microsoft.com>
  • Loading branch information
kevinfoley and keveleigh authored May 31, 2022
1 parent eb3125f commit 2cb1d75
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ private void OnEnable()
// Begin the follow coroutine when enabled.
AutoFollowAtDistance = autoFollowAtDistance;
}

private void OnDisable()
{
autoFollowDistanceCheck = null;
}

#endregion MonoBehaviour Implementation

Expand Down

0 comments on commit 2cb1d75

Please sign in to comment.