private static void Test() { UnityEvent ev = default; CharacterBody body = default; ev.AddPersistentListener(body, (b) => b.RecalculateStats()); }
public static void AddNewReaction(this SignalReceiver receiver, SignalAsset signalAsset) { if (signalAsset != null && receiver != null) { Undo.RecordObject(receiver, Styles.UndoAddReaction); var newEvent = new UnityEvent(); newEvent.AddPersistentListener(); var evtIndex = newEvent.GetPersistentEventCount() - 1; newEvent.RegisterVoidPersistentListenerWithoutValidation(evtIndex, receiver.gameObject, string.Empty); receiver.AddReaction(signalAsset, newEvent); PrefabUtility.RecordPrefabInstancePropertyModifications(receiver); } }
public static void AddNewReaction(this SignalReceiver receiver, SignalAsset signalAsset) { if (signalAsset != null && receiver != null) { Undo.RegisterCompleteObjectUndo(receiver, Styles.UndoAddReaction); var newEvent = new UnityEvent(); newEvent.AddPersistentListener(); var evtIndex = newEvent.GetPersistentEventCount() - 1; newEvent.RegisterVoidPersistentListenerWithoutValidation(evtIndex, receiver.gameObject, string.Empty); receiver.AddReaction(signalAsset, newEvent); } }
public static void AddPersistentListener <T0, T1, T2, T3>(UnityEvent <T0, T1, T2, T3> unityEvent, UnityAction <T0, T1, T2, T3> call) { unityEvent.AddPersistentListener(call); }
public static void AddPersistentListener(UnityEvent unityEvent, UnityAction call) { unityEvent.AddPersistentListener(call); }