From 0274022ce4693c030b221e3d7a2cfde433913d26 Mon Sep 17 00:00:00 2001 From: Sinai Date: Fri, 28 May 2021 18:23:07 +1000 Subject: [PATCH] Make sure WaitForEndOfFrame object is never null --- src/Core/Input/CursorUnlocker.cs | 4 ++-- src/UI/Widgets/ScrollPool/ScrollPool.cs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Core/Input/CursorUnlocker.cs b/src/Core/Input/CursorUnlocker.cs index f4fa575..3f823b9 100644 --- a/src/Core/Input/CursorUnlocker.cs +++ b/src/Core/Input/CursorUnlocker.cs @@ -62,13 +62,13 @@ namespace UnityExplorer.Core.Input } } - private static readonly WaitForEndOfFrame _waitForEndOfFrame = new WaitForEndOfFrame(); + private static WaitForEndOfFrame _waitForEndOfFrame = new WaitForEndOfFrame(); private static IEnumerator AggressiveUnlockCoroutine() { while (true) { - yield return _waitForEndOfFrame; + yield return _waitForEndOfFrame ?? (_waitForEndOfFrame = new WaitForEndOfFrame()); if (UIManager.ShowMenu) UpdateCursorControl(); diff --git a/src/UI/Widgets/ScrollPool/ScrollPool.cs b/src/UI/Widgets/ScrollPool/ScrollPool.cs index e9db77c..769e2ef 100644 --- a/src/UI/Widgets/ScrollPool/ScrollPool.cs +++ b/src/UI/Widgets/ScrollPool/ScrollPool.cs @@ -193,13 +193,12 @@ namespace UnityExplorer.UI.Widgets RuntimeProvider.Instance.StartCoroutine(InitCoroutine(onHeightChangedListener)); } - private readonly WaitForEndOfFrame waitForEndOfFrame = new WaitForEndOfFrame(); + private WaitForEndOfFrame waitForEndOfFrame = new WaitForEndOfFrame(); private IEnumerator InitCoroutine(Action onHeightChangedListener) { ScrollRect.content.anchoredPosition = Vector2.zero; - //yield return null; - yield return waitForEndOfFrame; + yield return waitForEndOfFrame ?? (waitForEndOfFrame = new WaitForEndOfFrame()); LayoutRebuilder.ForceRebuildLayoutImmediate(Content);