Skip to content

Commit a1d4131

Browse files
kevinfoleykeveleigh
andcommitted
Fix FollowMeToggle's auto-follow breaking if the component is disabled (#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 <[email protected]> Co-authored-by: Kurtis <[email protected]>
1 parent a223741 commit a1d4131

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ private void OnEnable()
183183
// Begin the follow coroutine when enabled.
184184
AutoFollowAtDistance = autoFollowAtDistance;
185185
}
186+
187+
private void OnDisable()
188+
{
189+
autoFollowDistanceCheck = null;
190+
}
186191

187192
#endregion MonoBehaviour Implementation
188193

0 commit comments

Comments
 (0)