From d47b70a4cfa2f7b7fa9ad92846adadae4407ce22 Mon Sep 17 00:00:00 2001 From: Kevin Foley Date: Fri, 27 May 2022 16:11:42 -0700 Subject: [PATCH 1/2] 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()`. --- Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs b/Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs index 9c5638f4400..7fe195ce2c2 100644 --- a/Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs +++ b/Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs @@ -183,6 +183,10 @@ private void OnEnable() // Begin the follow coroutine when enabled. AutoFollowAtDistance = autoFollowAtDistance; } + + private void OnDisable() { + autoFollowDistanceCheck = null; + } #endregion MonoBehaviour Implementation From 4b1af4695efcd679647f0e66e327dae877322069 Mon Sep 17 00:00:00 2001 From: Kevin Foley Date: Tue, 31 May 2022 12:13:14 -0700 Subject: [PATCH 2/2] FollowMeToggle: formatting tweak Per keveleigh Co-authored-by: Kurtis --- Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs b/Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs index 7fe195ce2c2..e9f49225887 100644 --- a/Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs +++ b/Assets/MRTK/SDK/Features/UX/Scripts/Slate/FollowMeToggle.cs @@ -184,7 +184,8 @@ private void OnEnable() AutoFollowAtDistance = autoFollowAtDistance; } - private void OnDisable() { + private void OnDisable() + { autoFollowDistanceCheck = null; }