//---------------------------------------------------------------------------------------------------------------------------------------- public void DrawExtrasAndDoAutoFill(Rect r) { // process auto fill for (var i = 0; i < _evnt.GetPersistentEventCount(); i++) { var target = _evnt.GetPersistentTarget(i); if (target) { continue; } if (_eventOwner is Component) { UnityEventTools.RegisterStringPersistentListener(_evnt, i, (_eventOwner as Component).SendMessage, ""); ResetMethodInProperty(i); } } var stl = new GUIStyle(GUI.skin.button) { padding = new RectOffset(), margin = new RectOffset(), overflow = new RectOffset(), normal = GUI.skin.label.normal }; // Draw Extra buttons var pec = _evnt.GetPersistentEventCount(); for (var i = 0; i < pec; i++) { switch (_mode) { case Mode.Browse: if (GUI.Button(new Rect(r.xMin - 14, r.yMin + (i * 43) + 25, 20, 33), eIcons.Get("icons/d_viewtoolzoom on.png"), stl)) { eEventDialog.Execute(BuildHackedData(i), _evnt.GetPersistentTarget(i)); } break; case Mode.Reorder: if (i > 0 && GUI.Button(new Rect(r.xMin - 14, r.yMin + (i * 43) + 20, 20, 20), "▲", stl)) { MoveUpHack(i); } if (i < (pec - 1) && GUI.Button(new Rect(r.xMin - 14, r.yMin + (i * 43) + 40, 20, 20), "▼", stl)) { MoveDownHack(i); } break; case Mode.Delete: if (GUI.Button(new Rect(r.xMin - 14, r.yMin + (i * 43) + 25, 20, 33), eIcons.Get("icons/d_winbtn_win_close.png"), stl)) { UnityEventTools.RemovePersistentListener(_evnt, i); } break; } } // draw Clear button if (GUI.Button(new Rect(r.xMax - 19, r.yMin + 1, 18, 16), eIcons.Get("icons/d_winbtn_win_close.png"), stl)) { while (_evnt.GetPersistentEventCount() > 0) { UnityEventTools.RemovePersistentListener(_evnt, 0); } } // draw Toolbar buttons eGUI.SetFGColor(new Color(1, 1, 1, 0), 0.9f); if (_mode == Mode.Browse) { eGUI.ResetColors(); } if (GUI.Button(new Rect(r.center.x - 39, r.yMax - 17, 26, 18), eIcons.Get("icons/d_viewtoolzoom on.png"), stl)) { _mode = Mode.Browse; } if (_mode == Mode.Browse) { eGUI.SetFGColor(new Color(1, 1, 1, 0), 0.9f); } if (_mode == Mode.Reorder) { eGUI.ResetColors(); } if (GUI.Button(new Rect(r.center.x - 13, r.yMax - 17, 26, 18), eIcons.Get("icons/d_rotatetool on.png"), stl)) { _mode = Mode.Reorder; } if (_mode == Mode.Reorder) { eGUI.SetFGColor(new Color(1, 1, 1, 0), 0.9f); } if (_mode == Mode.Delete) { eGUI.ResetColors(); } if (GUI.Button(new Rect(r.center.x + 13, r.yMax - 17, 26, 18), eIcons.Get("d_treeeditor.trash"), stl)) { _mode = Mode.Delete; } // draw Runtime count if (_runtimeCount > 0) { eGUI.SetFGColor(new Color(1, 0.3f, 0.3f), 0.9f); GUI.Label(new Rect(r.xMin, r.yMax - 16, 96, 16), "Runtime: " + _runtimeCount, EditorStyles.boldLabel); } }
public static void RegisterPersistentListener(this UnityEventBase self, int index, UnityAction <string> unityAction, string argument) { UnityEventTools.RegisterStringPersistentListener(self, index, unityAction, argument); }