unity-atoms/Packages/FSM/Runtime/FiniteStateMachine/FiniteStateMachineInstancer.cs
Adam Ramberg e4c489c88e WIP
2020-03-11 21:11:27 +01:00

30 lines
1.1 KiB
C#

using UnityEngine;
using UnityAtoms.BaseAtoms;
namespace UnityAtoms.FSM
{
[EditorIcon("atom-icon-hotpink")]
[AddComponentMenu("Unity Atoms/FSM/Finite State Machine Instancer")]
public class FiniteStateMachineInstancer : StringVariableInstancer
{
public override StringVariable Base { get => (StringVariable)_fsmBase; }
/// <summary>
/// The variable that the in memory copy will be based on when created at runtime.
/// </summary>
[SerializeField]
private FiniteStateMachine _fsmBase = null;
protected override void ImplSpecificSetup()
{
if (((FiniteStateMachine)Base).TransitionStarted != null)
{
((FiniteStateMachine)_inMemoryCopy).TransitionStarted = Instantiate(((FiniteStateMachine)Base).TransitionStarted);
}
if (((FiniteStateMachine)Base).CompleteCurrentTransition != null)
{
((FiniteStateMachine)_inMemoryCopy).CompleteCurrentTransition = Instantiate(((FiniteStateMachine)Base).CompleteCurrentTransition);
}
}
}
}