title: Why I cannot reach non-persistent listeners count from my UnityEvent?
body: <p>I need to know how many non-persistent listeners were added to a UnityEvent. </p>
  
  <p>It seems that there is no methods giving me this number in UnityEvent class. I can only get the persistent listeners count (the ones added from editor or with UnityEvent.AddPersistentListener() ). 
  The only solution I have figured out is to create a child class and override the function with a count of registrations.</p>
  
  <p>Here is a short code showing the problem :</p>
  
  <pre><code>    private UnityEvent myEvent;
  
      private void MyFunctionToHook()
      {
          // func logic
      }
  
      private void MyInitialisation()
      {
          myEvent.AddListener(MyFunctionToHook);
          myEvent.AddListener(MyFunctionToHook);
          myEvent.AddListener(MyFunctionToHook);
  
          // here, I need to know how much hooks were added.
          // ??
      }
  </code></pre>
  
  <p>1) Do you have any ideas of how I can manage to track this information natively?</p>
  
  <p>2) Am I doing this right ? Is it wrong wanting to know this information ?</p>
  
  <p>It seems weird to not have access to this info, because it could be useful in unit-tests / warnings..etc</p>
  
  <p>Thanks for your time.</p>
  
  <p>Here is the unityEvent documentation : <a href="https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html" rel="noreferrer">https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html</a></p>
  
  <p>[EDIT]
  the only solution I have found so far is the following : </p>
  
  <pre><code>    public class TrackingUnityEvent&lt;T0&gt; : UnityEvent&lt;T0&gt;
  {
      private int nonPersistentListenersCount;
  
      public int GetNonPersistentEventCount()
      {
          return nonPersistentListenersCount;
      }
  
      public void AddNonPersistantListener(UnityAction&lt;T0&gt; call)
      {
          AddListener(call);
          nonPersistentListenersCount++;
      }
  
      public void RemoveNonPersistantListener(UnityAction&lt;T0&gt; call)
      {
          RemoveListener(call);
          nonPersistentListenersCount--;
      }
  }
  </code></pre>
  
  <p>This way is gross because you can't tell if "RemoveListener()" and "AddListener()" are successfull as they are void. </p>