///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.isActive? 0.8f : 0.25f); GUI.enabled = !Application.isPlaying; action.isActive = EditorGUILayout.Toggle(action.isActive, 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))) { Undo.RecordObject(ownerSystem.contextObject, "List Remove Task"); actions.RemoveAt(i); } 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); }
//The action list gui public void ShowListGUI() { if (ownerSystem == null) { GUILayout.Label("Owner System is null!"); return; } EditorUtils.TaskSelectionButton <ActionTask>(ownerSystem, (a) => { AddAction(a); }); 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 = new Color(1, 1, 1, 0.25f); EditorGUILayout.BeginHorizontal("box"); GUI.color = action.isActive? new Color(1, 1, 1, 0.8f) : new Color(1, 1, 1, 0.25f); 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.isPaused? "<b>||</b> " : action.isRunning? "► " : "") + action.summaryInfo, GUILayout.MinWidth(0), GUILayout.ExpandWidth(true)); if (!Application.isPlaying && GUILayout.Button("X", GUILayout.Width(20))) { Undo.RecordObject(ownerSystem.contextObject, "List Remove Task"); actions.RemoveAt(i); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); EditorGUILayout.EndHorizontal(); GUI.color = Color.white; }); executionMode = (ActionsExecutionMode)EditorGUILayout.EnumPopup(executionMode); }
void DoLoadPreset() { var path = EditorUtility.OpenFilePanel("Load Preset", "Assets", "actionList"); if (!string.IsNullOrEmpty(path)) { var json = System.IO.File.ReadAllText(path); var list = JSONSerializer.Deserialize <ActionList>(json); this.actions = list.actions; this.executionMode = list.executionMode; this.currentViewAction = null; foreach (var a in actions) { a.SetOwnerSystem(this.ownerSystem); } } }
public void DoLoadPreset() { #if !UNITY_WEBPLAYER var path = EditorUtility.OpenFilePanel("Load Preset", "Assets", "actionList"); if (!string.IsNullOrEmpty(path)) { var json = System.IO.File.ReadAllText(path); var list = JSONSerializer.Deserialize <ActionList>(json); this.actions = list.actions; this.executionMode = list.executionMode; this.currentViewAction = null; foreach (var a in actions) { a.SetOwnerSystem(this.ownerSystem); } } #else Debug.LogWarning("Preset loading is not possible with WebPlayer as active platform"); #endif }
//The action list gui public void ShowListGUI() { if (ownerSystem == null){ Debug.LogError("Owner System = null !"); return; } EditorUtils.TaskSelectionButton<ActionTask>(ownerSystem, (a)=>{ AddAction(a); }); ValidateList(); if (actions.Count == 0){ EditorGUILayout.HelpBox("No Actions", MessageType.None); return; } if (actions.Count == 1) return; //show the actions EditorUtils.ReorderableList(actions, delegate(int i){ var action = actions[i]; GUI.color = new Color(1, 1, 1, 0.25f); EditorGUILayout.BeginHorizontal("box"); GUI.color = action.isActive? new Color(1,1,1,0.8f) : new Color(1,1,1,0.25f); 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.isPaused? "<b>||</b> " : action.isRunning? "► " : "") + action.summaryInfo, GUILayout.MinWidth(0), GUILayout.ExpandWidth(true)); if (!Application.isPlaying && GUILayout.Button("X", GUILayout.Width(20))){ Undo.RecordObject(ownerSystem.baseObject, "List Remove Task"); actions.RemoveAt(i); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); EditorGUILayout.EndHorizontal(); GUI.color = Color.white; }); executionMode = (ActionsExecutionMode)EditorGUILayout.EnumPopup(executionMode); }
public void DoLoadPreset() { #if !UNITY_WEBPLAYER var path = EditorUtility.OpenFilePanel("Load Preset", "Assets", "actionList"); if (!string.IsNullOrEmpty(path)){ var json = System.IO.File.ReadAllText(path); var list = JSON.Deserialize<ActionList>(json); this.actions = list.actions; this.executionMode = list.executionMode; this.currentViewAction = null; foreach(var a in actions){ a.SetOwnerSystem(this.ownerSystem); } } #else Debug.LogWarning("Preset loading is not possible with WebPlayer as active platform"); #endif }