public void AddAction(ActionTask action) { if (action is ActionList) { foreach (var subAction in (action as ActionList).actions) { AddAction(subAction); } return; } #if UNITY_EDITOR if (!Application.isPlaying) { Undo.RecordObject(ownerSystem.contextObject, "List Add Task"); currentViewAction = action; } #endif actions.Add(action); action.SetOwnerSystem(this.ownerSystem); // action.isActive = true; }
///Show the sub-tasks list public void ShowListGUI() { if (ownerSystem == null) { GUILayout.Label("Owner System is null!"); return; } TaskEditor.ShowCreateTaskSelectionButton <ActionTask>(ownerSystem, AddAction); ValidateList(); if (actions.Count == 0) { EditorGUILayout.HelpBox("No Actions", MessageType.None); return; } if (actions.Count == 1) { return; } //show the actions EditorUtils.ReorderableList(actions, (i, picked) => { var action = actions[i]; GUI.color = Color.white.WithAlpha(action == currentViewAction ? 0.75f : 0.25f); EditorGUILayout.BeginHorizontal("box"); GUI.color = Color.white.WithAlpha(action.isUserEnabled ? 0.8f : 0.25f); GUI.enabled = !Application.isPlaying; action.isUserEnabled = EditorGUILayout.Toggle(action.isUserEnabled, GUILayout.Width(18)); GUI.enabled = true; GUILayout.Label((action.isPaused ? "<b>||</b> " : action.isRunning ? "► " : "") + action.summaryInfo, GUILayout.MinWidth(0), GUILayout.ExpandWidth(true)); if (!Application.isPlaying && GUILayout.Button("X", GUILayout.Width(20))) { UndoUtility.RecordObject(ownerSystem.contextObject, "List Remove Task"); actions.RemoveAt(i); if (actions.Count == 1) { actions[0].isUserEnabled = true; } } EditorGUILayout.EndHorizontal(); var lastRect = GUILayoutUtility.GetLastRect(); EditorGUIUtility.AddCursorRect(lastRect, MouseCursor.Link); if (Event.current.type == EventType.MouseDown && lastRect.Contains(Event.current.mousePosition)) { currentViewAction = action == currentViewAction ? null : action; Event.current.Use(); } GUI.color = Color.white; }); executionMode = (ActionsExecutionMode)EditorGUILayout.EnumPopup(executionMode); }