-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathSwitchOnState.cs
More file actions
26 lines (19 loc) · 891 Bytes
/
SwitchOnState.cs
File metadata and controls
26 lines (19 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SwitchOnState : StateMachineBehaviour {
public string Information;
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
Call(animator, true);
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
Call(animator, false);
}
void Call(Animator animator, bool state)
{
animator.gameObject.GetComponent<ModularController>().Switch(Information, state);
}
}