50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
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<IAwake>(true);
|
|
self.starts = root.GetComponentsInChildren<IStart>(true);
|
|
self.updates = root.GetComponentsInChildren<IUpdate>(true);
|
|
self.fixedUpdates = root.GetComponentsInChildren<IFixedUpdate>(true);
|
|
self.lateUpdates = root.GetComponentsInChildren<ILateUpdate>(true);
|
|
self.destroys = root.GetComponentsInChildren<IDestroy>(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 };
|
|
}
|
|
}
|
|
}
|
|
} |