using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class UpdateManager : MonoBehaviour { [SerializeField] private List<GameObject> tests; public List<IUpdatable> updatables= new List<IUpdatable>(); private void Start() { foreach (GameObject test in tests) { updatables.Add(test.GetComponent<IUpdatable>()); } } public void AddToList(IUpdatable source) { updatables.Add(source); } public void RemoveFromList(IUpdatable source) { updatables.Remove(source); } void Update() { for(int i = 0; i < updatables.Count; i++) { if (updatables[i] != null) updatables[i].Updating(); } } }