예제 #1
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);
 }
예제 #2
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);
        }
예제 #3
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);
        }