//Update public virtual void Execute(Rect editorRect, Rect precentageRect, Event e, EngineGraph currentGraph) { if (_viewSkin == null) { GetEditorSkin(); return; } this.currentGraph = currentGraph; if (currentGraph != null) { viewTitle = currentGraph.graphName; } viewRect = new Rect(editorRect.x * precentageRect.x, editorRect.y * precentageRect.y, editorRect.width * precentageRect.width, editorRect.height * precentageRect.height); }
public override void Execute(Rect editorRect, Rect precentageRect, Event e, EngineGraph currentGraph) { base.Execute(editorRect, precentageRect, e, currentGraph); GUI.Box(viewRect, viewTitle, _viewSkin.GetStyle("ViewBG")); if (Event.current.type == EventType.Repaint) { GridGUI(); } if (currentGraph != null) { Rect canvasRect = viewRect; currentGraph.zoomPanAdjust = BeginScale(ref viewRect, _zoomPos, currentGraph.zoom); } GUILayout.BeginArea(viewRect); if (currentGraph != null) { currentGraph.UpdateGraphGUI(e, viewRect, _viewSkin); } GUILayout.EndArea(); ProcessEvents(e); if (currentGraph != null) { EndScale(); } _fixedMousePose = Event.current.mousePosition; OnShowMenu(); OnShowMenu = delegate { }; }
public override void Execute(Rect editorRect, Rect precentageRect, Event e, EngineGraph currentGraph) { base.Execute(editorRect, precentageRect, e, currentGraph); if (currentGraph != null) { if (currentGraph.selectedNode) { viewTitle = currentGraph.selectedNode.nodeName; } } else { _paramAccess = ParamAccessibility.IsGlobal; } GUILayout.BeginArea(viewRect); ShowToolbarGUI(); GUILayout.BeginArea(new Rect(new Vector2(precentageRect.x, viewRect.y + 8), new Vector2(viewRect.width, 24))); GUILayout.BeginHorizontal(_toolbar); //Show the menu and add a new parameter. if (GUILayout.Button("Add parameter", _button, GUILayout.Width(100))) { GenericMenu menu = new GenericMenu(); if (currentGraph == null) { menu.AddDisabledItem(new GUIContent("Int")); menu.AddDisabledItem(new GUIContent("Float")); menu.AddDisabledItem(new GUIContent("Bool")); menu.AddDisabledItem(new GUIContent("String")); } else { menu.AddItem(new GUIContent("Int"), false, () => parameters.SuscribeValue($"Parameter {parameters.Count}", ParamVariableType.Int, currentGraph, _paramAccess)); menu.AddItem(new GUIContent("Float"), false, () => parameters.SuscribeValue($"Parameter {parameters.Count}", ParamVariableType.Float, currentGraph, _paramAccess)); menu.AddItem(new GUIContent("Bool"), false, () => parameters.SuscribeValue($"Parameter {parameters.Count}", ParamVariableType.Bool, currentGraph, _paramAccess)); menu.AddItem(new GUIContent("String"), false, () => parameters.SuscribeValue($"Parameter {parameters.Count}", ParamVariableType.String, currentGraph, _paramAccess)); } menu.Show(new Vector2(precentageRect.x + 5, viewRect.y + 14)); } GUILayout.Space(5); string accessName = _paramAccess == ParamAccessibility.IsGlobal ? "Global" : "Local"; //Show the menu and select the parameters of the selected accessibility. if (GUILayout.Button(accessName, _button, GUILayout.Width(50))) { GenericMenu menu = new GenericMenu(); if (currentGraph == null) { menu.AddDisabledItem(new GUIContent("Show Global")); menu.AddDisabledItem(new GUIContent("Show Local")); } else { menu.AddItem(new GUIContent("Show Global"), false, () => _paramAccess = ParamAccessibility.IsGlobal); menu.AddItem(new GUIContent("Show Local"), false, () => _paramAccess = ParamAccessibility.IsLocal); } menu.Show(new Vector2(precentageRect.x + 110, viewRect.y + 14)); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(precentageRect.x, viewRect.y * 2 + 24, viewRect.width, viewRect.height)); GUILayout.BeginVertical("BOX"); var selectedParams = _paramAccess == ParamAccessibility.IsGlobal ? parameters.Where(x => x.access == ParamAccessibility.IsGlobal) : parameters.Where(x => x.access == ParamAccessibility.IsLocal).Where(x => x.graph == currentGraph); if (!selectedParams.Any()) { GUILayout.BeginVertical("BOX"); GUILayout.Label("Empty", new GUIStyle() { alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Italic }); GUILayout.EndVertical(); } else { GUILayout.BeginVertical(); _pos = GUILayout.BeginScrollView(_pos, GUILayout.Width(viewRect.width)); foreach (var(Name, Type, Access, Graph, IsPersistent) in selectedParams) { GUILayout.Space(5); GUILayout.BeginHorizontal("BOX"); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); string itemIsPersist; string itemValue; if (Type == ParamVariableType.Int) { var item = parameters.GetInt(Name); itemIsPersist = IsPersistent ? "P: " : ""; itemValue = $"Int: {item.Value}"; } else if (Type == ParamVariableType.Float) { var item = parameters.GetFloat(Name); itemIsPersist = IsPersistent ? "P: " : ""; itemValue = $"Float: {item.Value}"; } else if (Type == ParamVariableType.String) { var item = parameters.GetString(Name); itemIsPersist = IsPersistent ? "P:" : ""; itemValue = $"String: {item.Value}"; } else { var item = parameters.GetBool(Name); itemIsPersist = IsPersistent ? "P: " : ""; itemValue = $"Bool: {item.Value}"; } GUILayout.Label($"{itemIsPersist} {Name}"); GUILayout.Label(itemValue); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (_toDelete && _nameToDelete.Equals(Name)) { if (GUILayout.Button("Delete")) { EngineGraphWindow.OnRepaintRequest += () => { parameters.UnsuscribeValue(_nameToDelete); _nameToDelete = ""; AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }; } if (GUILayout.Button("Cancel")) { _toDelete = false; _nameToDelete = ""; } } else { if (GUILayout.Button("Edit")) { System.Action <string> OnSave = name => { var editingParam = Name; var editedName = name; EngineGraphWindow.OnRepaintRequest += () => { var graphs = Resources.LoadAll("Data").Select(x => x as EngineGraph).Where(x => x != null); if (graphs.Any()) { foreach (var item in graphs) { var checkCondition = item.nodes.Where(x => x.nodeType == EnumNodeType.Condition); if (checkCondition.Any()) { var conditions = checkCondition.Select(x => (NCondition)x) .Where(x => x.data.Contains(editingParam)); foreach (var node in conditions) { node.data.UpdateName(editingParam, editedName); EditorUtility.SetDirty(node); } } var checkSetter = item.nodes.Where(x => x.nodeType == EnumNodeType.Set_Param); if (checkSetter.Any()) { var setters = checkSetter.Select(x => (NSetParam)x) .Where(x => x.data.Any(y => y.Name == editingParam)); foreach (var node in setters) { node.data.UpdateName(editingParam, editedName); EditorUtility.SetDirty(node); } } } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }; }; if (Type == ParamVariableType.Int) { EditVariablePopupWindow.InitContainerPopup(parameters.GetInt(Name), OnSave); } else if (Type == ParamVariableType.Float) { EditVariablePopupWindow.InitContainerPopup(parameters.GetFloat(Name), OnSave); } else if (Type == ParamVariableType.Bool) { EditVariablePopupWindow.InitContainerPopup(parameters.GetBool(Name), OnSave); } else { EditVariablePopupWindow.InitContainerPopup(parameters.GetString(Name), OnSave); } } if (GUILayout.Button("Delete")) { _toDelete = true; _nameToDelete = Name; } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); } GUILayout.Space(30); GUILayout.EndVertical(); GUILayout.EndScrollView(); } GUILayout.EndVertical(); GUILayout.EndArea(); GUILayout.EndArea(); }
public override void Execute(Rect editorRect, Rect precentageRect, Event e, EngineGraph currentGraph) { _textStyle = new GUIStyle(GUI.skin.label) { fontSize = 12, alignment = TextAnchor.UpperCenter, onNormal = new GUIStyleState() { textColor = Color.white } }; base.Execute(editorRect, precentageRect, e, currentGraph); _style = new GUIStyle(GUI.skin.box); ShowCreatePanelGUI(); GUILayout.BeginHorizontal(_toolbar); if (GUILayout.Button("File", _dropdown, GUILayout.Width(50))) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Create Graph"), false, () => showDialogue = true); menu.AddItem(new GUIContent("Load Graph"), false, EngineGraphEditorUtilities.LoadGraph); menu.AddSeparator(""); if (currentGraph == null) { menu.AddDisabledItem(new GUIContent("Unload Graph")); menu.AddDisabledItem(new GUIContent("Delete Graph")); } else { currentGraph.selectedNode = null; menu.AddItem(new GUIContent("Delete Graph/Confirm"), false, EngineGraphEditorUtilities.DeleteGraph); menu.AddItem(new GUIContent("Unload Graph"), false, EngineGraphEditorUtilities.UnloadGraph); } menu.Show(new Vector2(5, 17)); } GUILayout.Space(10); if (GUILayout.Button("Insert", _dropdown, GUILayout.Width(100))) { GenericMenu menu = new GenericMenu(); if (currentGraph != null) { currentGraph.selectedNode = null; menu.AddItem(new GUIContent("Story State/Add Text State", "Write dialogues and narrative text in the text container."), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Text, new Vector2(50, 50))); menu.AddItem(new GUIContent("Story State/Add Clear Text State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Clear, new Vector2(50, 50))); menu.AddItem(new GUIContent("Story State/Add Change Flow Chart State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Flow_Chart, new Vector2(50, 50))); menu.AddItem(new GUIContent("Character State/Add Show Character State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Show_Character, new Vector2(50, 50))); menu.AddItem(new GUIContent("Character State/Add Hide Character State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Hide_Character, new Vector2(50, 50))); menu.AddItem(new GUIContent("Character State/Add Change Character Sprite State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Character_Sprite, new Vector2(50, 50))); menu.AddItem(new GUIContent("Character State/Add Character Move State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Move_Character, new Vector2(50, 50))); menu.AddItem(new GUIContent("Image State/Add Change Background State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Background, new Vector2(50, 50))); menu.AddItem(new GUIContent("Effect State/Add Delay State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Delay, new Vector2(50, 50))); menu.AddItem(new GUIContent("Effect State/Add Show Text Container"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Show_Text_Container, new Vector2(50, 50))); menu.AddItem(new GUIContent("Effect State/Add Hide Text Container"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Hide_Text_Container, new Vector2(50, 50))); menu.AddItem(new GUIContent("Sound State/Music/Add Play Music State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Music, new Vector2(50, 50))); menu.AddItem(new GUIContent("Sound State/Music/Add Stop Music State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Music, new Vector2(50, 50))); menu.AddItem(new GUIContent("Sound State/Sound FX/Add Play Sound State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Sound, new Vector2(50, 50))); menu.AddItem(new GUIContent("Sound State/Sound FX/Add Stop SouSoundnd State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Sound, new Vector2(50, 50))); menu.AddItem(new GUIContent("Sound State/Voice/Add Play Voice State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Voice, new Vector2(50, 50))); menu.AddItem(new GUIContent("Sound State/Voice/Add Stop Voice State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Voice, new Vector2(50, 50))); menu.AddItem(new GUIContent("Branch State/Add Question Branch State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Branch_Question, new Vector2(50, 50))); menu.AddItem(new GUIContent("Branch State/Add Conditional Branch State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Branch_Condition, new Vector2(50, 50))); menu.AddSeparator("Branch State/"); menu.AddItem(new GUIContent("Branch State/Add Answer State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Answer, new Vector2(50, 50))); menu.AddItem(new GUIContent("Branch State/Add Condition State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Condition, new Vector2(50, 50))); menu.AddItem(new GUIContent("System State/Add Set Parameter State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Set_Param, new Vector2(50, 50))); menu.AddItem(new GUIContent("System State/Add Trigger Event State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Set_Param, new Vector2(50, 50))); } else { menu.AddDisabledItem(new GUIContent("Story State/Add Text State")); menu.AddDisabledItem(new GUIContent("Story State/Add Clear Text State")); menu.AddDisabledItem(new GUIContent("Story State/Add Change Flow Chart State")); menu.AddDisabledItem(new GUIContent("Character State/Add Show Character State")); menu.AddDisabledItem(new GUIContent("Character State/Add Hide Character State")); menu.AddDisabledItem(new GUIContent("Character State/Add Change Character Sprite State")); menu.AddDisabledItem(new GUIContent("Character State/Add Character Move State")); menu.AddDisabledItem(new GUIContent("Image State/Add Change Background State")); menu.AddDisabledItem(new GUIContent("Effect State/Add Delay State")); menu.AddDisabledItem(new GUIContent("Effect State/Add Show Text Container")); menu.AddDisabledItem(new GUIContent("Effect State/Add Hide Text Container")); menu.AddDisabledItem(new GUIContent("Sound State/Music/Add Play Music State")); menu.AddDisabledItem(new GUIContent("Sound State/Music/Add Stop Music State")); menu.AddDisabledItem(new GUIContent("Sound State/Sound FX/Add Play Sound State")); menu.AddDisabledItem(new GUIContent("Sound State/Sound FX/Add Stop Sound State")); menu.AddDisabledItem(new GUIContent("Sound State/Voice/Add Play Voice State")); menu.AddDisabledItem(new GUIContent("Sound State/Voice/Add Stop Voice State")); menu.AddDisabledItem(new GUIContent("Branch State/Add Question Branch State")); menu.AddDisabledItem(new GUIContent("Branch State/Add Conditional Brach State")); menu.AddSeparator("Branch State/"); menu.AddDisabledItem(new GUIContent("Branch State/Add Answer State")); menu.AddDisabledItem(new GUIContent("Branch State/Add Condition State")); menu.AddDisabledItem(new GUIContent("System State/Add Set Parameter State")); menu.AddDisabledItem(new GUIContent("System State/Add Trigger Event State")); } menu.Show(new Vector2(65, 17)); } if (GUILayout.Button("Tools", _dropdown, GUILayout.Width(80))) { GenericMenu menu = new GenericMenu(); //menu.AddDisabledItem(new GUIContent("Import/XML")); //menu.AddDisabledItem(new GUIContent("Import/TXT")); //menu.AddDisabledItem(new GUIContent("Export/XML")); //menu.AddDisabledItem(new GUIContent("Export/TXT")); menu.AddItem(new GUIContent("Clear cache", "Clear the cache information of the last session."), false, EngineGraphCacheUtilities.ClearSessionCache); menu.Show(new Vector2(135, 17)); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (showDialogue) { CreateGraphDialogueGUI(); } }