コード例 #1
0
        public static ICodeBehaviour AddBehaviour(this GameObject gameObject, StateMachine stateMachine)
        {
            ICodeBehaviour behaviour = gameObject.AddComponent <ICodeBehaviour> ();

            behaviour.stateMachine = stateMachine;
            behaviour.EnableStateMachine();
            return(behaviour);
        }
コード例 #2
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (behaviour == null)
     {
         behaviour = animator.gameObject.AddBehaviour(stateMachine);
     }
     else
     {
         behaviour.EnableStateMachine();
         (behaviour.ActiveNode as State).Restart();
     }
 }
コード例 #3
0
        public static ICodeBehaviour AddBehaviour(this GameObject gameObject, StateMachine stateMachine, int group, bool replaceIfExists)
        {
            ICodeBehaviour behaviour = gameObject.GetBehaviour(group);

            if (behaviour != null && replaceIfExists)
            {
                behaviour.stateMachine = stateMachine;
                behaviour.EnableStateMachine();
            }
            else
            {
                behaviour       = gameObject.AddBehaviour(stateMachine);
                behaviour.group = group;
            }
            return(behaviour);
        }
コード例 #4
0
 private void Start()
 {
     if (behaviour.stateMachine != null)
     {
         if (!behaviour.stateMachine.IsInitialized)
         {
             bool isEnabled = behaviour.enabled;
             behaviour.EnableStateMachine();
             behaviour.enabled = isEnabled;
         }
         for (int i = 0; i < setVariables.Count; i++)
         {
             FsmVariable variable = behaviour.stateMachine.GetVariable(setVariables[i].name);
             if (variable != null)
             {
                 variable.SetValue(setVariables[i].GetValue());
             }
         }
     }
 }