/************************************************************************************************************************/

        private static void AddEventClipboardItems(GenericMenu menu, SerializedProperty property,
                                                   Serialization.PropertyAccessor accessor)
        {
            // Copy Event.
            menu.AddItem(new GUIContent("Copy Event"), false, () =>
            {
                Clipboard.CopyEvent(property);
            });

            // Paste Event.
            AddMenuItem(menu, "Paste Event (Overwrite)", Clipboard.HasEvent, () =>
            {
                property.ModifyValues <UltEventBase>((e) =>
                {
                    Clipboard.Paste(e);
                }, "Paste Event");
            });

            // Paste Listener.
            AddMenuItem(menu, "Paste Listener (New) %#V", Clipboard.HasCall, () =>
            {
                property.ModifyValues <UltEventBase>((e) =>
                {
                    var call = new PersistentCall();
                    Clipboard.PasteCall(call);

                    if (e._PersistentCalls == null)
                    {
                        e._PersistentCalls = new List <PersistentCall>();
                    }
                    e._PersistentCalls.Add(call);
                }, "Paste PersistentCall");
            });
        }
        /************************************************************************************************************************/

        private static void AddCallClipboardItems(GenericMenu menu, SerializedProperty property,
                                                  Serialization.PropertyAccessor accessor)
        {
            menu.AddItem(new GUIContent("Copy Listener %C"), false, () =>
            {
                Clipboard.CopyCall(property);
            });

            AddMenuItem(menu, "Paste Listener (Overwrite) %V", Clipboard.HasCall, () => Clipboard.PasteCall(property));
        }
        /************************************************************************************************************************/

        public static void AddEventFunctions(GenericMenu menu, SerializedProperty property,
                                             Serialization.PropertyAccessor accessor)
        {
            property = property.Copy();

            if (accessor.FieldType == typeof(UltEvent))
            {
                menu.AddItem(new GUIContent("Invoke Event"), false, () =>
                {
                    var events = property.GetValues <UltEvent>();
                    for (int i = 0; i < events.Length; i++)
                    {
                        var e = events[i] as UltEvent;
                        if (e != null)
                        {
                            e.Invoke();
                        }
                    }
                    property.OnPropertyChanged();
                });
            }

            AddEventClipboardItems(menu, property, accessor);

            menu.AddItem(new GUIContent("Clear Event"), false, () =>
            {
                property.ModifyValues <UltEventBase>((e) =>
                {
                    if (e != null)
                    {
                        e.Clear();
                    }
                }, "Clear Event");
            });

            menu.AddItem(new GUIContent("Log Description"), false, () =>
            {
                var targets = property.serializedObject.targetObjects;
                var events  = property.GetValues <UltEventBase>();

                for (int i = 0; i < events.Length; i++)
                {
                    Debug.Log(events[i], targets[i]);
                }
            });
        }
Ejemplo n.º 4
0
        /// <summary>Stores the details of the call contained in the specified property.</summary>
        public static void CopyCall(Serialization.PropertyAccessor accessor, Object target)
        {
            var call = (PersistentCall)accessor.GetValue(target);

            CopyCall(call);
        }
Ejemplo n.º 5
0
        /// <summary>Stores the details of the event contained in the specified property.</summary>
        public static void CopyEvent(Serialization.PropertyAccessor accessor, Object target)
        {
            var e = (UltEventBase)accessor.GetValue(target);

            CopyEvent(e);
        }