public static bool DrawCustomEventInspectorBar(bool expanded, GameObject senderGameObject, out EventSender newSender) { EventSender sender = senderGameObject.GetComponent <EventSender>(); EditorGUILayout.BeginHorizontal(); EditorGUILayoutExt.BeginLabelStyle(12, FontStyle.Bold, new Color(0.45f, 0.45f, 0.45f), null); expanded = GUILayout.Button(expanded ? "▼" : "►", GUI.skin.label, GUILayout.ExpandWidth(false)) ? !expanded : expanded; if (sender != null) { bool enabled = GUILayout.Toggle(sender.enabled, "", GUILayout.ExpandWidth(false)); if (enabled != sender.enabled) { sender.enabled = enabled; } } EditorGUILayoutExt.BeginLabelStyle(null, null, new Color(0.72f, 1f, 0.72f), null); if (sender != null) { expanded = GUILayout.Button(sender.GetType().Name, GUI.skin.label, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)) ? !expanded : expanded; } else { expanded = GUILayout.Button("Event: None!", GUI.skin.label, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)) ? !expanded : expanded; } GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace(); EditorGUILayoutExt.EndLabelStyle(); EditorGUILayoutExt.EndLabelStyle(); Type eventType = TriggerGUILayout.DrawEventSelector(sender != null ? sender.GetType() : null); if (eventType != null) { if (sender == null || eventType != sender.GetType()) { GameObject.DestroyImmediate(sender); sender = (EventSender)senderGameObject.AddComponent(eventType); } } else { GameObject.DestroyImmediate(sender); sender = null; } EditorGUILayout.EndHorizontal(); newSender = sender; return(expanded); }