public void Panel() { var pos = _scene.position; GUILayout.BeginArea(new Rect(pos.width - 260, pos.height - 120, 250, 175)); var rec = EditorGUILayout.BeginVertical(); GUI.color = new Color32(200, 200, 200, 230); GUI.Box(rec, GUIContent.none); GUILayout.Space(5); GUILayout.Label("GraphPlayer quick access", _title); if (GUILayout.Button("Open FlowChart")) { EngineGraphWindow.InitEditorWindow(); EngineGraphEditorUtilities.LoadSession(_behaviour.graph); } GUILayout.Space(2); if (GUILayout.Button("Open Database")) { VNDatabaseWindow.InitParadoxDatabaseWindow(); } GUILayout.Space(2); if (GUILayout.Button("Help")) { EngineInstructionWindow.InitInstructionWindow(); } GUILayout.Space(5); EditorGUILayout.EndVertical(); GUILayout.EndArea(); }
private void CreateGraphDialogueGUI() { GUILayout.BeginArea(new Rect(20, 40, 250, 70), _style); GUILayout.Label("Create Graph", _textStyle); GUILayout.BeginHorizontal(); GUILayout.Label("Name:"); _graphName = GUILayout.TextField(_graphName, GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create")) { if (!string.IsNullOrEmpty(_graphName)) { EngineGraphEditorUtilities.CreateNewGraph(_graphName); showDialogue = false; } else { EditorUtility.DisplayDialog("Paradox Engine", "The name isn't valid.", "OK"); } } if (GUILayout.Button("Cancel")) { _graphName = ""; showDialogue = false; } GUILayout.EndHorizontal(); GUILayout.EndArea(); }
private void OnGUI() { GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical(); EditorGUILayout.LabelField("Create a new Graph Player:", EditorStyles.boldLabel); containerName = EditorGUILayout.TextField("Enter name: ", containerName); GUILayout.Space(5); EditorGUI.BeginChangeCheck(); _prefab = (GameObject)EditorGUILayout.ObjectField("Container Prefab", _prefab, typeof(GameObject), true); _canvas = (GameObject)EditorGUILayout.ObjectField("Canvas:", _canvas, typeof(GameObject), true); if (_canvas != null && !_canvas.GetComponent <Canvas>()) { _canvas = null; } if (EditorGUI.EndChangeCheck()) { Repaint(); } if (_canvas == null) { EditorGUILayout.HelpBox("The canvas can't be null.", MessageType.Error); } if (_prefab == null) { EditorGUILayout.HelpBox("The Container prefab can't be null.", MessageType.Error); } GUILayout.Space(10); GUILayout.BeginHorizontal(); if (_prefab != null && _canvas != null) { if (GUILayout.Button("Create Paradox Player", GUILayout.Height(40))) { if (!string.IsNullOrEmpty(containerName) && containerName != "Enter a name..." && containerName != " ") { EngineGraphEditorUtilities.CreateContainer(_prefab, _canvas, containerName); containerPopup.Close(); } else { EditorUtility.DisplayDialog("Container Message", "Please, insert a valid name.", "OK"); } } } if (GUILayout.Button("Cancel", GUILayout.Height(40))) { containerPopup.Close(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(20); GUILayout.EndHorizontal(); GUILayout.Space(20); }
private void Inspector() { _title = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, fontSize = 14, fontStyle = FontStyle.Bold, wordWrap = true }; EditorGUILayout.Space(); EditorGUILayout.LabelField("GraphPlayer Behaviour", _title); EditorGUI.DrawRect(GUILayoutUtility.GetRect(100, 2), Color.black); GUILayout.Space(5); GUILayout.Label("GraphPlayer quick access", new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter }); if (GUILayout.Button("Open FlowChart")) { EngineGraphWindow.InitEditorWindow(); EngineGraphEditorUtilities.LoadSession(_behaviour.graph); } GUILayout.Space(2); if (GUILayout.Button("Open Database")) { VNDatabaseWindow.InitParadoxDatabaseWindow(); } GUILayout.Space(2); if (GUILayout.Button("Help")) { EngineInstructionWindow.InitInstructionWindow(); } EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); string graphPath = ""; if (_behaviour.graph != null) { EditorGUILayout.LabelField("Node Graph:"); EditorGUILayout.LabelField(_behaviour.graph.name, new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter }); } GUILayout.Space(2); if (GUILayout.Button("Load Graph")) { graphPath = EditorUtility.OpenFilePanel("Load Graph", Application.dataPath + "/Paradox Engine/Graph/Resources/Data/", ""); } if (graphPath != "") { int appPathLen = Application.dataPath.Length; string finalPath = graphPath.Substring(appPathLen - 6); _behaviour.graph = (EngineGraph)AssetDatabase.LoadAssetAtPath(finalPath, typeof(EngineGraph)); } GUILayout.Space(10); _behaviour.cache = (ParadoxSessionCache)EditorGUILayout.ObjectField("Session cache: ", _behaviour.cache, typeof(ParadoxSessionCache), false); _behaviour.settings = (DSetting)EditorGUILayout.ObjectField("Setting: ", _behaviour.settings, typeof(DSetting), false); _behaviour.localizationManager = (ParadoxEngine.Localization.LocalizationManager)EditorGUILayout.ObjectField("Localization manager: ", _behaviour.localizationManager, typeof(ParadoxEngine.Localization.LocalizationManager), true); _behaviour.characterContainer = (Transform)EditorGUILayout.ObjectField("Character container: ", _behaviour.characterContainer, typeof(Transform), true); GUILayout.Space(15); EditorGUILayout.LabelField("Background Containers:", new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold }); GUILayout.Space(5); _behaviour.backgrounds[0] = (UnityEngine.UI.Image)EditorGUILayout.ObjectField("Background 1: ", _behaviour.backgrounds[0], typeof(UnityEngine.UI.Image), true); _behaviour.backgrounds[1] = (UnityEngine.UI.Image)EditorGUILayout.ObjectField("Background 2: ", _behaviour.backgrounds[1], typeof(UnityEngine.UI.Image), true); GUILayout.Space(10); EditorGUILayout.LabelField("Text Containers:", new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold }); GUILayout.Space(5); _behaviour.textContainer = (UnityEngine.UI.Text)EditorGUILayout.ObjectField("Text container: ", _behaviour.textContainer, typeof(UnityEngine.UI.Text), true); _behaviour.characterNameContainer = (UnityEngine.UI.Text)EditorGUILayout.ObjectField("Character name container: ", _behaviour.characterNameContainer, typeof(UnityEngine.UI.Text), true); GUILayout.Space(10); EditorGUILayout.LabelField("Audio Containers:", new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold }); GUILayout.Space(5); _behaviour.musicChannel[0] = (AudioSource)EditorGUILayout.ObjectField("Music channel 1: ", _behaviour.musicChannel[0], typeof(AudioSource), true); _behaviour.musicChannel[1] = (AudioSource)EditorGUILayout.ObjectField("Music channel 2: ", _behaviour.musicChannel[1], typeof(AudioSource), true); _behaviour.soundChannel = (AudioSource)EditorGUILayout.ObjectField("Sound channel: ", _behaviour.soundChannel, typeof(AudioSource), true); _behaviour.voiceChannel = (AudioSource)EditorGUILayout.ObjectField("Voice channel: ", _behaviour.voiceChannel, typeof(AudioSource), true); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(_behaviour); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } Repaint(); }
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(); } }
void ProcessContextMenu(Event e, int contextID) { GenericMenu menu = new GenericMenu(); if (contextID == 0) { menu.AddItem(new GUIContent("Create Graph"), false, EngineGraphEditorUtilities.OpenNewGraphPanel); menu.AddItem(new GUIContent("Load Graph"), false, EngineGraphEditorUtilities.LoadGraph); if (currentGraph != null) { menu.AddSeparator(""); menu.AddItem(new GUIContent("Unload Graph"), false, EngineGraphEditorUtilities.UnloadGraph); menu.AddSeparator(""); menu.AddItem(new GUIContent("Story State/Add Text State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Text, mousePos)); menu.AddItem(new GUIContent("Story State/Add Clear Text State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Clear, mousePos)); menu.AddItem(new GUIContent("Story State/Add Change Flow Chart State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Flow_Chart, mousePos)); menu.AddItem(new GUIContent("Character State/Add Show Character State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Show_Character, mousePos)); menu.AddItem(new GUIContent("Character State/Add Hide Character State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Hide_Character, mousePos)); menu.AddItem(new GUIContent("Character State/Add Change Character Sprite State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Character_Sprite, mousePos)); menu.AddItem(new GUIContent("Character State/Add Move Character State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Move_Character, mousePos)); menu.AddItem(new GUIContent("Image State/Add Change Background State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Background, mousePos)); menu.AddItem(new GUIContent("Effect State/Add Delay State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Delay, mousePos)); menu.AddItem(new GUIContent("Effect State/Add Show Text Container"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Show_Text_Container, mousePos)); menu.AddItem(new GUIContent("Effect State/Add Hide Text Container"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Hide_Text_Container, mousePos)); menu.AddItem(new GUIContent("Sound State/Music/Add Play Music State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Music, mousePos)); menu.AddItem(new GUIContent("Sound State/Music/Add Stop Music State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Music, mousePos)); menu.AddItem(new GUIContent("Sound State/Sound FX/Add Play Sound State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Sound, mousePos)); menu.AddItem(new GUIContent("Sound State/Sound FX/Add Stop Sound State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Sound, mousePos)); menu.AddItem(new GUIContent("Sound State/Voice/Add Play Voice State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Voice, mousePos)); menu.AddItem(new GUIContent("Sound State/Voice/Add Stop Voice State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Voice, mousePos)); menu.AddItem(new GUIContent("Branch State/Add Question Branch State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Branch_Question, mousePos)); menu.AddItem(new GUIContent("Branch State/Add Conditional Branch State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Branch_Condition, mousePos)); menu.AddSeparator("Branch State/"); menu.AddItem(new GUIContent("Branch State/Add Answer State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Answer, mousePos)); menu.AddItem(new GUIContent("Branch State/Add Condition State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Condition, mousePos)); menu.AddItem(new GUIContent("System State/Add Set Parameter State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Set_Param, mousePos)); menu.AddItem(new GUIContent("System State/Add Trigger Event State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Trigger_Event, mousePos)); } } if (contextID == 1) { if (currentGraph != null) { menu.AddItem(new GUIContent("Delete State"), false, () => EngineGraphEditorUtilities.DeleteNode(currentGraph, overNodeID)); menu.AddItem(new GUIContent("Disconnect/Disconnect Input"), false, () => EngineGraphEditorUtilities.DisconnectInput(currentGraph, overNodeID)); menu.AddItem(new GUIContent("Disconnect/Disconnect Output"), false, () => EngineGraphEditorUtilities.DisconnectOutput(currentGraph, overNodeID)); menu.AddItem(new GUIContent("Disconnect/Disconnect All"), false, () => EngineGraphEditorUtilities.DisconnectAll(currentGraph, overNodeID)); } } if (contextID == 2) { if (currentGraph != null) { menu.AddItem(new GUIContent("Disconnect Output"), false, () => EngineGraphEditorUtilities.DisconnectOutput(currentGraph, overNodeID)); } } if (contextID == 3) { if (currentGraph != null) { menu.AddItem(new GUIContent("Disconnect Input"), false, () => EngineGraphEditorUtilities.DisconnectInput(currentGraph, overNodeID)); } } if (contextID == 4) { if (currentGraph != null) { menu.AddItem(new GUIContent("Delete State"), false, () => EngineGraphEditorUtilities.DeleteNode(currentGraph, overNodeID)); menu.AddItem(new GUIContent("Disconnect Input"), false, () => EngineGraphEditorUtilities.DisconnectInput(currentGraph, overNodeID)); } } OnShowMenu += () => { menu.Show(_fixedMousePose); e.Use(); }; }