示例#1
0
 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);
     }
 }
示例#2
0
        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);
            }
        }