//The action list gui public void ShowListGUI() { if (this == null) { return; } //button to add new actions EditorUtils.TaskSelectionButton(gameObject, typeof(ActionTask), delegate(Task a){ AddAction((ActionTask)a); }); //check list and possibly remove trully null entries ValidateList(); if (actions.Count == 0) { EditorGUILayout.HelpBox("No Actions", MessageType.None); return; } //show the actions EditorUtils.ReorderableList(actions, delegate(int i){ var o = actions[i]; var action = actions[i] as ActionTask; GUI.color = new Color(1, 1, 1, 0.25f); EditorGUILayout.BeginHorizontal("box"); if (action != null) { GUI.color = action.isActive? new Color(1, 1, 1, 0.8f) : new Color(1, 1, 1, 0.25f); Undo.RecordObject(action, "Mute"); action.isActive = EditorGUILayout.Toggle(action.isActive, GUILayout.Width(18)); GUI.backgroundColor = action == currentViewAction? Color.grey : Color.white; if (GUILayout.Button(EditorUtils.viewIcon, GUILayout.Width(25), GUILayout.Height(18))) { currentViewAction = action == currentViewAction? null : action; } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); GUI.backgroundColor = Color.white; GUILayout.Label((action.isRunning? "► " : action.isPaused? "<b>||</b> " : "") + action.summaryInfo); } else { GUILayout.Label(MissingTaskText(o)); GUI.color = Color.white; } if (GUILayout.Button("X", GUILayout.Width(20))) { Undo.RecordObject(this, "List Remove Task"); actions.RemoveAt(i); Undo.DestroyObjectImmediate(o); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); EditorGUILayout.EndHorizontal(); GUI.color = Color.white; }); if (actions.Count > 1) { runInParallel = EditorGUILayout.ToggleLeft("Run In Parallel", runInParallel); } }
public void ShowListGUI() { if (this == null) { return; } EditorUtils.TaskSelectionButton(gameObject, typeof(ConditionTask), delegate(Task c){ AddCondition((ConditionTask)c); }); ValidateList(); if (conditions.Count == 0) { EditorGUILayout.HelpBox("No Conditions", MessageType.None); return; } EditorUtils.ReorderableList(conditions, delegate(int i){ var o = conditions[i]; var condition = conditions[i] as ConditionTask; GUI.color = new Color(1, 1, 1, 0.25f); GUILayout.BeginHorizontal("box"); if (condition != null) { GUI.color = condition.isActive? new Color(1, 1, 1, 0.8f) : new Color(1, 1, 1, 0.25f); Undo.RecordObject(condition, "Mute"); condition.isActive = EditorGUILayout.Toggle(condition.isActive, GUILayout.Width(18)); GUI.backgroundColor = condition == currentViewCondition? Color.grey : Color.white; if (GUILayout.Button(EditorUtils.viewIcon, GUILayout.Width(25), GUILayout.Height(18))) { currentViewCondition = condition == currentViewCondition? null : condition; } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); GUI.backgroundColor = Color.white; GUILayout.Label(condition.summaryInfo); } else { GUILayout.Label(MissingTaskText(o)); GUI.color = Color.white; } if (GUILayout.Button("X", GUILayout.MaxWidth(20))) { Undo.RecordObject(this, "List Remove Task"); conditions.RemoveAt(i); Undo.DestroyObjectImmediate(o); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); GUILayout.EndHorizontal(); GUI.color = Color.white; }); EditorUtils.Separator(); if (conditions.Count > 1) { GUI.backgroundColor = new Color(0.5f, 0.5f, 0.5f); if (GUILayout.Button(allSuccessRequired? "ALL True Required":"ANY True Suffice")) { allSuccessRequired = !allSuccessRequired; } GUI.backgroundColor = Color.white; } }
public void ShowVariablesGUI() { GUI.backgroundColor = new Color(0.8f, 0.8f, 1); if (GUILayout.Button("Add Variable")) { GenericMenu.MenuFunction2 Selected = delegate(object selectedType){ Undo.RecordObject(this, "New Variable"); var newData = AddData("my" + EditorUtils.TypeName((Type)selectedType), (Type)selectedType); Undo.RegisterCreatedObjectUndo(newData, "New Variable"); }; var assetPaths = AssetDatabase.GetAllAssetPaths().Select(p => EditorUtils.Strip(p, "/")).ToList(); var menu = new GenericMenu(); foreach (KeyValuePair <Type, Type> pair in GetTypeDataRelation()) { if (typeof(MonoBehaviour).IsAssignableFrom(pair.Key)) { if (!assetPaths.Contains(pair.Key.Name + ".cs") && !assetPaths.Contains(pair.Key.Name + ".js") && !assetPaths.Contains(pair.Key.Name + ".boo")) { Debug.LogWarning(string.Format("Class Name {0} is different from it's script name", pair.Key.Name)); continue; } } menu.AddItem(new GUIContent((!string.IsNullOrEmpty(pair.Value.Namespace)? pair.Value.Namespace + "/": "") + EditorUtils.TypeName(pair.Value)), false, Selected, pair.Value); menu.ShowAsContext(); Event.current.Use(); } } GUI.backgroundColor = Color.white; if (variables.Count != 0) { GUILayout.BeginHorizontal(); GUI.color = Color.yellow; GUILayout.Label("Name", GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true)); GUILayout.Label("Value", GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true)); GUI.color = Color.white; GUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("Blackboard has no variables", MessageType.Info); } EditorUtils.ReorderableList(variables, delegate(int i){ var data = variables[i]; if (data != null) { GUILayout.BeginHorizontal(); if (!Application.isPlaying) { GUI.backgroundColor = new Color(1, 1, 1, 0.8f); GUILayout.Box("", GUILayout.Width(6)); GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.3f); data.dataName = EditorGUILayout.TextField(data.dataName, GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true)); } else { GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f); GUI.color = new Color(0.8f, 0.8f, 1f); GUILayout.Label(data.dataName, GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true)); } GUI.color = Color.white; GUI.backgroundColor = Color.white; Undo.RecordObject(data, "Data Change"); data.ShowDataGUI(); if (GUI.changed) { EditorUtility.SetDirty(data); } GUI.color = Color.white; GUI.backgroundColor = Color.white; if (GUILayout.Button("X", GUILayout.Width(20), GUILayout.Height(16))) { if (EditorUtility.DisplayDialog("Delete Data '" + data.dataName + "'", "Are you sure?", "Yes", "No!")) { Undo.DestroyObjectImmediate(data); Undo.RecordObject(this, "Delete Data"); variables.Remove(data); } } GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f); GUILayout.EndHorizontal(); } }); GUI.backgroundColor = Color.white; GUI.color = Color.white; if (GUI.changed) { EditorUtility.SetDirty(this); } }