public static void Open(EditorTutorialScripts owner, TutorialScript script, TutorialStep step, Vector2 position, float buttonWidth) { var rect = new Rect(position, new Vector2(200, 200)); if (_eventWindow == null) { _eventWindow = EditorWindow.GetWindowWithRect <EditorAddTutorialEvent>(rect, true, "添加事件"); } else { _eventWindow.position = rect; } _eventWindow._owner = owner; _eventWindow._step = step; _eventWindow._script = script; _eventWindow._buttonWidth = buttonWidth; _eventWindow.Show(); }
void DrawEvents(ref List <TutorialEvent> events, ref bool show, TutorialScript ts, TutorialStep step, Vector2 pos, bool isPublic) { // 事件列表 EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); show = EditorGUILayout.Foldout(show, (isPublic ? "公共" : "") + "事件列表"); if (GUILayout.Button("添加" + (isPublic ? "公共" : "") + "事件", GUILayout.Width(_buttonWidth))) { EditorAddTutorialEvent.Open(_currentWindow, ts, step, pos, _buttonWidth); } EditorGUILayout.EndHorizontal(); if (show) { List <TutorialEvent> removeEvents = new List <TutorialEvent>(); for (int j = 0; j < events.Count; ++j) { EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("事件" + (j + 1) + ": " + events[j].GetType().ToString()); GUILayout.FlexibleSpace(); if (GUILayout.Button("删除事件", GUILayout.Width(_buttonWidth))) { removeEvents.Add(events[j]); break; } EditorGUILayout.EndHorizontal(); JsonUtils.DisplayInEditor(events[j], _buttonWidth); } for (int j = 0; j < removeEvents.Count; ++j) { events.Remove(removeEvents[j]); } } EditorGUILayout.EndVertical(); }