title: Better way to create Events inside StateMachineBehaviour scripts (Unity)
body: <p>I would like to use events on <code>StateMachineBehaviour</code> instead of using <code>bool</code> parameters. But I was having a problem using delegate events.</p>
  
  <pre><code>public class DeficateState : StateMachineBehaviour {
  public delegate void DeficateEvent();
  public static event DeficateEvent OnPoop;
  public static event DeficateEvent OnPee;
  
  override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
  {
      if (!update) return;
      if (times &gt; IdleTime)
      {
          update = false;
          times = 0;
          if(animator.GetInteger("IdleIndex") == 0){
              if (OnPoop != null)
                  OnPoop();
          }else{
              if (OnPee != null)
                  OnPee();
          }
      }
      times += Time.deltaTime;
  }
  </code></pre>
  
  <p>I was able to unsubscribe manually. Carelessly when I missed some, errors like "m_Animator is destroyed but you are trying to access..." appears, making me spend more time to review my code.
  Could there be more effective and better way of using events on <code>StateMachineBehaviour</code> without using delegate events?</p>