///Show the sub-tasks list public void ShowListGUI() { TaskEditor.ShowCreateTaskSelectionButton <ConditionTask>(ownerSystem, AddCondition); ValidateList(); if (conditions.Count == 0) { EditorGUILayout.HelpBox("No Conditions", MessageType.None); return; } if (conditions.Count == 1) { return; } EditorUtils.ReorderableList(conditions, (i, picked) => { var condition = conditions[i]; GUI.color = Color.white.WithAlpha(condition == currentViewCondition ? 0.75f : 0.25f); GUILayout.BeginHorizontal("box"); GUI.color = Color.white.WithAlpha(condition.isUserEnabled ? 0.8f : 0.25f); GUI.enabled = !Application.isPlaying; condition.isUserEnabled = EditorGUILayout.Toggle(condition.isUserEnabled, GUILayout.Width(18)); GUI.enabled = true; GUILayout.Label(condition.summaryInfo, GUILayout.MinWidth(0), GUILayout.ExpandWidth(true)); if (!Application.isPlaying && GUILayout.Button("X", GUILayout.MaxWidth(20))) { UndoUtility.RecordObject(ownerSystem.contextObject, "List Remove Task"); conditions.RemoveAt(i); if (conditions.Count == 1) { conditions[0].isUserEnabled = true; } } GUILayout.EndHorizontal(); var lastRect = GUILayoutUtility.GetLastRect(); EditorGUIUtility.AddCursorRect(lastRect, MouseCursor.Link); if (Event.current.type == EventType.MouseDown && lastRect.Contains(Event.current.mousePosition)) { currentViewCondition = condition == currentViewCondition ? null : condition; Event.current.Use(); } GUI.color = Color.white; }); checkMode = (ConditionsCheckMode)EditorGUILayout.EnumPopup(checkMode); }
public void ShowListGUI() { EditorUtils.TaskSelectionButton <ConditionTask>(ownerSystem, (c) => { AddCondition(c); }); ValidateList(); if (conditions.Count == 0) { EditorGUILayout.HelpBox("No Conditions", MessageType.None); return; } if (conditions.Count == 1) { return; } EditorUtils.ReorderableList(conditions, (i, picked) => { var condition = conditions[i]; GUI.color = new Color(1, 1, 1, 0.25f); GUILayout.BeginHorizontal("box"); GUI.color = condition.isActive? new Color(1, 1, 1, 0.8f) : new Color(1, 1, 1, 0.25f); 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, GUILayout.MinWidth(0), GUILayout.ExpandWidth(true)); if (!Application.isPlaying && GUILayout.Button("X", GUILayout.MaxWidth(20))) { Undo.RecordObject(ownerSystem.contextObject, "List Remove Task"); conditions.RemoveAt(i); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); GUILayout.EndHorizontal(); GUI.color = Color.white; }); checkMode = (ConditionsCheckMode)EditorGUILayout.EnumPopup(checkMode); }
void DoLoadPreset() { var path = EditorUtility.OpenFilePanel("Load Preset", "Assets", "conditionList"); if (!string.IsNullOrEmpty(path)) { var json = System.IO.File.ReadAllText(path); var list = JSONSerializer.Deserialize <ConditionList>(json); this.conditions = list.conditions; this.checkMode = list.checkMode; this.currentViewCondition = null; foreach (var a in conditions) { a.SetOwnerSystem(this.ownerSystem); } } }
void AddCondition(ConditionTask condition) { if (condition is ConditionList) { Debug.LogWarning("Adding a ConditionList within another ConditionList is not allowed for clarity"); return; } #if UNITY_EDITOR if (!Application.isPlaying) { Undo.RecordObject(ownerSystem.contextObject, "List Add Task"); currentViewCondition = condition; } #endif conditions.Add(condition); condition.SetOwnerSystem(this.ownerSystem); }
public void AddCondition(ConditionTask condition) { if (condition is ConditionList) { foreach (var subCondition in (condition as ConditionList).conditions) { AddCondition(subCondition); } return; } #if UNITY_EDITOR UndoUtility.RecordObject(ownerSystem.contextObject, "List Add Task"); currentViewCondition = condition; #endif conditions.Add(condition); condition.SetOwnerSystem(this.ownerSystem); }
public void DoLoadPreset() { #if !UNITY_WEBPLAYER var path = EditorUtility.OpenFilePanel("Load Preset", "Assets", "conditionList"); if (!string.IsNullOrEmpty(path)) { var json = System.IO.File.ReadAllText(path); var list = JSONSerializer.Deserialize <ConditionList>(json); this.conditions = list.conditions; this.checkMode = list.checkMode; this.currentViewCondition = null; foreach (var a in conditions) { a.SetOwnerSystem(this.ownerSystem); } } #else Debug.LogWarning("Preset loading is not possible with WebPlayer as active platform"); #endif }
public void ShowNestedConditionsGUI() { if (conditions.Count == 1) { currentViewCondition = conditions[0]; } if (currentViewCondition != null) { EditorUtils.Separator(); Task.ShowTaskInspectorGUI(currentViewCondition, (c) => { if (c == null) { var i = conditions.IndexOf(currentViewCondition); conditions.RemoveAt(i); } currentViewCondition = (ConditionTask)c; }); } }