public AttachEventInfo(AttachEventType eventType, AttachObject attachObject, MonoBehaviour sender = null) { this.eventType = eventType; this.attachObject = attachObject; this.attachment = attachObject.attachment; this.sender = null; }
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); } }
public bool HasVisibleEntryForEventType(AttachEventType eventType) { foreach (Entry e in entries) { if (e.eventType == eventType) { return(!e.hideInInspector); } } return(false); }
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(); }
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); }