Beispiel #1
0
 /// <summary>
 /// Gets the total event count (sum of runtime and persistent events). Beware this is a hack using reflection.
 /// </summary>
 public int GetTotalEventCount()
 {
     if (!UnityEventReflection.TryAccessCalls(this, ref _callsObject))
     {
         return(0);
     }
     return(UnityEventReflection.GetEventCount(_callsObject) + GetPersistentEventCount());
 }
Beispiel #2
0
 /// <summary>
 /// Removes a persistent listener. Beware this is a hack using reflection.
 /// </summary>
 public void RemovePersistentListener(UnityAction <T> action)
 {
     if (!UnityEventReflection.TryAccessPersistentCalls(this, ref _persistentCallsObject))
     {
         return;
     }
     UnityEventReflection.RemovePersistentListener(_persistentCallsObject, action.Target as UnityEngine.Object, action.Method);
 }
Beispiel #3
0
        /// <summary>
        /// Adds a persistent listener. Beware this is a hack using reflection.
        /// </summary>
        public void AddPersistentListener(UnityAction action)
        {
            if (!UnityEventReflection.TryAccessPersistentCalls(this, ref _persistentCallsObject))
            {
                return;
            }
            int index = GetPersistentEventCount();

            UnityEventReflection.AddPersistentListner(_persistentCallsObject, index, action.Target as UnityEngine.Object, action.Method);
        }
Beispiel #4
0
        /// <summary>
        /// Adds a persistent listener. Beware this is a hack using reflection.
        /// </summary>
        public void AddPersistentListener(UnityAction <T> action, UnityEventCallState state = UnityEventCallState.RuntimeOnly)
        {
            if (!UnityEventReflection.TryAccessPersistentCalls(this, ref _persistentCallsObject))
            {
                return;
            }
            int index = GetPersistentEventCount();

            UnityEventReflection.AddPersistentListner(_persistentCallsObject, index, action.Target as UnityEngine.Object, action.Method);
            SetPersistentListenerState(index, state);
        }