public static State AddState(StateMachine machine, StateLayer layer, Type stateType) { State state = null; #if UNITY_EDITOR state = Array.Find(machine.GetComponents(stateType), component => component.GetType() == stateType) as State; state = state == null ? machine.AddComponent(stateType) as State : state; state = AddState(machine, layer, state); #endif return state; }
public static StateLayer AddLayer(StateMachine machine, Type layerType, UnityEngine.Object parent) { StateLayer layer = null; #if UNITY_EDITOR layer = Array.Find(machine.GetComponents(layerType), component => component.GetType() == layerType) as StateLayer; layer = layer == null ? machine.AddComponent(layerType) as StateLayer : layer; layer = AddLayer(machine, layer, parent); #endif return layer; }