using System; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace BITKit { public static partial class BehaviourUpdaterExtensions { public static void Init(this BehaviorUpdater self, Component root) { self.awakes = root.GetComponentsInChildren(true); self.starts = root.GetComponentsInChildren(true); self.updates = root.GetComponentsInChildren(true); self.fixedUpdates = root.GetComponentsInChildren(true); self.lateUpdates = root.GetComponentsInChildren(true); self.destroys = root.GetComponentsInChildren(true); } public static void Init(this BehaviorUpdater self, object root) { if (root is IAwake awake) { self.awakes = new IAwake[1] { awake }; } if (root is IStart start) { self.starts = new IStart[1] { start }; } if (root is IStop stop) { self.stops = new IStop[1] { stop }; } if (root is IUpdate update) { self.updates = new IUpdate[1] { update }; } if (root is IFixedUpdate fixedUpdate) { self.fixedUpdates = new IFixedUpdate[1] { fixedUpdate }; } if (root is ILateUpdate lateUpdate) { self.lateUpdates = new ILateUpdate[1] { lateUpdate }; } if (root is IDestroy destroy) { self.destroys = new IDestroy[1] { destroy }; } } } }