diff --git a/ThirdParty/UpdateManager/Scripts/ManagedUpdateRegisterer.cs b/ThirdParty/UpdateManager/Scripts/ManagedUpdateRegisterer.cs index d8205fca2..a561f487c 100644 --- a/ThirdParty/UpdateManager/Scripts/ManagedUpdateRegisterer.cs +++ b/ThirdParty/UpdateManager/Scripts/ManagedUpdateRegisterer.cs @@ -1,26 +1,27 @@ +using System.Collections.Generic; using UnityEngine; namespace Insthync.ManagedUpdating { public class ManagedUpdateRegisterer : MonoBehaviour { - private IManagedUpdateBase[] _updaters = null; + private readonly List _updaters = new(); private bool _prepared = false; private void Prepare() { if (_prepared) return; + _prepared = true; - _updaters = GetComponents(); + GetComponents(_updaters); } private void OnEnable() { Prepare(); - if (_updaters == null) - return; - for (int i = 0; i < _updaters.Length; ++i) + + for (int i = 0, count = _updaters.Count; i < count; ++i) { UpdateManager.Register(_updaters[i]); } @@ -28,9 +29,7 @@ private void OnEnable() private void OnDisable() { - if (_updaters == null) - return; - for (int i = 0; i < _updaters.Length; ++i) + for (int i = 0, count = _updaters.Count; i < count; ++i) { UpdateManager.Unregister(_updaters[i]); }