コード例 #1
0
 public AttachEventInfo(AttachEventType eventType, AttachObject attachObject, MonoBehaviour sender = null)
 {
     this.eventType    = eventType;
     this.attachObject = attachObject;
     this.attachment   = attachObject.attachment;
     this.sender       = null;
 }
コード例 #2
0
        void Notify(AttachEvent evt, string message, AttachEventType eventType)
        {
            AttachEventInfo info = new AttachEventInfo(eventType, this);

            seedObject.SendMessage(message, info, SendMessageOptions.DontRequireReceiver);
            if (evt != null)
            {
                evt.Invoke(info);
            }
        }
コード例 #3
0
 public bool HasVisibleEntryForEventType(AttachEventType eventType)
 {
     foreach (Entry e in entries)
     {
         if (e.eventType == eventType)
         {
             return(!e.hideInInspector);
         }
     }
     return(false);
 }
コード例 #4
0
        private void ShowAddTriggerMenu(AttachEventTrigger eventTrigger)
        {
            GenericMenu genericMenu = new GenericMenu();

            for (int i = 0; i < eventTrigger.supportedEventTypes.Length; i++)
            {
                AttachEventType eventType = eventTrigger.supportedEventTypes[i];
                if (!eventTrigger.HasVisibleEntryForEventType(eventTrigger.supportedEventTypes[i]))
                {
                    genericMenu.AddItem(new GUIContent(eventType.ToString()), false,
                                        new GenericMenu.MenuFunction2((object index) => {
                        eventTrigger.GetOrCreateEvent(eventType, hideInInspector: false);
                    }), i);
                }
                else
                {
                    genericMenu.AddDisabledItem(new GUIContent(eventType.ToString()));
                }
            }
            genericMenu.ShowAsContext();
            Event.current.Use();
        }
コード例 #5
0
        public AttachEvent GetOrCreateEvent(AttachEventType eventType, bool hideInInspector = true)
        {
            foreach (Entry e in entries)
            {
                if (e.eventType == eventType)
                {
                    if (!hideInInspector)
                    {
                        e.hideInInspector = false;
                    }
                    return(e.callback);
                }
            }
            Entry entry = new Entry();

            entry.eventType = eventType;
            if (!hideInInspector)
            {
                entry.hideInInspector = false;
            }
            entries.Add(entry);
            return(entry.callback);
        }