Make sure WaitForEndOfFrame object is never null

This commit is contained in:
Sinai 2021-05-28 18:23:07 +10:00
parent 211576e0f8
commit 0274022ce4
2 changed files with 4 additions and 5 deletions

View File

@ -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() private static IEnumerator AggressiveUnlockCoroutine()
{ {
while (true) while (true)
{ {
yield return _waitForEndOfFrame; yield return _waitForEndOfFrame ?? (_waitForEndOfFrame = new WaitForEndOfFrame());
if (UIManager.ShowMenu) if (UIManager.ShowMenu)
UpdateCursorControl(); UpdateCursorControl();

View File

@ -193,13 +193,12 @@ namespace UnityExplorer.UI.Widgets
RuntimeProvider.Instance.StartCoroutine(InitCoroutine(onHeightChangedListener)); RuntimeProvider.Instance.StartCoroutine(InitCoroutine(onHeightChangedListener));
} }
private readonly WaitForEndOfFrame waitForEndOfFrame = new WaitForEndOfFrame(); private WaitForEndOfFrame waitForEndOfFrame = new WaitForEndOfFrame();
private IEnumerator InitCoroutine(Action onHeightChangedListener) private IEnumerator InitCoroutine(Action onHeightChangedListener)
{ {
ScrollRect.content.anchoredPosition = Vector2.zero; ScrollRect.content.anchoredPosition = Vector2.zero;
//yield return null; yield return waitForEndOfFrame ?? (waitForEndOfFrame = new WaitForEndOfFrame());
yield return waitForEndOfFrame;
LayoutRebuilder.ForceRebuildLayoutImmediate(Content); LayoutRebuilder.ForceRebuildLayoutImmediate(Content);