public override void OnInspectorGUI() { //if dr is null some kind of load occurred if (dr == null) { dr = (DialogueReader)target; } options = FillPopUp(); int ct = 0; foreach (string s in options) { if (s == dr.dialogueID) { currSelection = ct; break; //just this once } ct++; } base.OnInspectorGUI(); lastSelection = currSelection; currSelection = EditorGUILayout.Popup("Select Dialogue Tree", currSelection, options); if (lastSelection != currSelection) { Undo.RecordObject(dr, "Dialogue ID Change"); dr.dialogueID = options[currSelection]; } }
private void Awake() { if (instance != this && instance != null) { Destroy(this.gameObject); return; } instance = this; TextAsset dialogueData = Resources.Load <TextAsset>("DialogueInfo"); string[] data = dialogueData.text.Split(new char[] { '\n' }); for (int i = 1; i < data.Length; i++) { string[] row = data[i].Split(new char[] { ',' }); Dialogue dial = new Dialogue(); dial.key = row[0]; int.TryParse(row[0], out dial.id); dial.name = row[2]; dial.dialogue = row[1]; int.TryParse(row[3], out dial.characterModel); allDialogues.Add(dial); dialogueDictionnary.Add(dial.key, dial); } if (ValueHolder.instance) { _language = ValueHolder.instance.gameLanguage; } }
// Use this for initialization void Start () { reader = GameObject.FindObjectOfType<DialogueReader>(); if(reader == null) { Debug.LogError("--No Dialogue Reader--//The UIDialogue Can not find a dialogue reader in the scene."); } else { reader.NewDialogueEntered += EnteredNewDialogue; } charRef = GameObject.FindObjectOfType<CharacterRefernece>(); }
public void ReadCSV() //Assets/DynamicFiles/System/SystemFiles/dialoguesdialogues.csv { for (int i = 0; i < fileName.Length; i++) { string file_path = "Assets/DynamicFiles/System/SystemFiles/dialogues/" + fileName[i] + ".csv"; switch (fileName[i]) { case "Dialogues": Dialogue = DialogueReader.Reader(file_path); break; case "OptionList": Option = OptionListReader.Reader(file_path); break; default: break; } } //StreamReader sr = null; //for (int i = 0; i < fileName.Length; i++) //{ //try //{ //string file_url = "Assets/DynamicFiles/System/SystemFiles/dialogues/" + fileName[i] + ".csv"; //sr = File.OpenText(file_url); //} //catch //{ // Debug.Log("File not found"); // return; //} //string line; //while ((line = sr.ReadLine()) != null) //{ // switch (fileName[i]) // { // case "Dialogues": // ReadDiaolgues(line); // break; // default: // break; // } //} //} //sr.Close(); //sr.Dispose(); }
void OnGUI() { reader = (DialogueReader)EditorUtility.InstanceIDToObject(instanceId); if (reader != null) { DrawActors(); } if (GUI.changed) { EditorUtility.SetDirty(reader); } }
void Start() { fileLoader = new FileLoader(); xmlReader = new XmlReader(); dialogue = new DialogueReader(); textSpoken.text = ""; string data = fileLoader.Load("TestDialogue.xml"); Dialogue d = xmlReader.Deserialize<Dialogue>(data) as Dialogue; dialogue.SetDialogue(d); }
private void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } m_DialogueReader = GetComponent <DialogueReader>(); }
//Draws editable list of keys void OnGUI() { reader = (DialogueReader)EditorUtility.InstanceIDToObject(instanceId); if (reader != null) { int spacer = 10; EditorGUIUtility.labelWidth = 80; GUILayout.BeginArea(new Rect(spacer, spacer, position.width - spacer * 2, position.height - spacer * 2), GUI.skin.box); EditorGUILayout.LabelField("Key List", DialogueEditor.NewStyle("", 15, Color.white, FontStyle.Bold)); GUILayout.Space(spacer); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Name", EditorStyles.label)) { SortKeys("name"); } if (GUILayout.Button("Number", EditorStyles.label, GUILayout.Width(position.width / 5))) { SortKeys("number"); } EditorGUILayout.EndHorizontal(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); for (int i = 0; i < reader.Keys.Count; i++) { Key key = reader.Keys[i]; EditorGUILayout.BeginHorizontal(); key.name = EditorGUILayout.TextField(key.name); key.number = EditorGUILayout.IntField(key.number, GUILayout.Width(position.width / 5)); if (GUILayout.Button("Delete")) { reader.Keys.Remove(key); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); newName = EditorGUILayout.TextField(newName); newNum = EditorGUILayout.IntField(newNum, GUILayout.Width(position.width / 5)); if (GUILayout.Button("Create")) { CreateNewKey(newName, newNum); } EditorGUILayout.EndHorizontal(); GUILayout.EndArea(); } if (GUI.changed) { EditorUtility.SetDirty(reader); } }
// Start is called before the first frame update void Start() { controller = FindObjectOfType <FirstPersonController>(); baloon = FindObjectOfType <PopupBaloon>(); aSource = GetComponent <AudioSource>(); reader = new DialogueReader(); if (baloon != null) { baloon.transform.gameObject.SetActive(false); } mapObject = new Dictionary <string, HIntObject>(); mapGroup = new Dictionary <string, List <string> >(); InitializeMaps(); }
//activate buttons, set dialogue from root of tree public void InitDialogue(DialogueReader givenReader, AudioSource givenAudioSource) { dialogueReader = givenReader; audioSource = givenAudioSource; dialogueTree = dialogueReader.GetTree(); if (dialogueTree != null) { currDialogue = dialogueTree.GoToRoot(); speaker.text = dialogueTree.GetSpeaker(); ActivateButtons(-1, true); SetAll(); audioSource.clip = currDialogue.GetAudioDialogue(); audioSource.Play(); } }
//Draws editable list of keys void OnGUI() { reader = (DialogueReader)EditorUtility.InstanceIDToObject(instanceId); if (reader != null){ int spacer = 10; EditorGUIUtility.labelWidth = 80; GUILayout.BeginArea (new Rect(spacer, spacer, position.width - spacer * 2, position.height - spacer * 2), GUI.skin.box); EditorGUILayout.LabelField("Key List", DialogueEditor.NewStyle("", 15, Color.white, FontStyle.Bold)); GUILayout.Space(spacer); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Name", EditorStyles.label)) SortKeys("name"); if (GUILayout.Button("Number", EditorStyles.label, GUILayout.Width(position.width/5))) SortKeys("number"); EditorGUILayout.EndHorizontal(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); for(int i = 0; i < reader.Keys.Count; i++){ Key key = reader.Keys[i]; EditorGUILayout.BeginHorizontal(); key.name = EditorGUILayout.TextField(key.name); key.number = EditorGUILayout.IntField(key.number, GUILayout.Width(position.width/5)); if (GUILayout.Button("Delete")) reader.Keys.Remove(key); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); newName = EditorGUILayout.TextField(newName); newNum = EditorGUILayout.IntField(newNum, GUILayout.Width(position.width/5)); if (GUILayout.Button("Create")) CreateNewKey(newName, newNum); EditorGUILayout.EndHorizontal(); GUILayout.EndArea(); } if (GUI.changed) EditorUtility.SetDirty(reader); }
// Use this for initialization void Start() { readerObject = GameObject.FindGameObjectWithTag("GameController").GetComponent<DialogueReader>(); }
public virtual void TriggerDialogue(DialogueReader reader) { if(numTimesCantrigger > 0) { reader.AddDialogue(conversation); numTimesCantrigger--; } }
private void Awake() { Instance = this; }
void OnGUI() { reader = (DialogueReader)EditorUtility.InstanceIDToObject(instanceId); if (reader != null) DrawActors(); if (GUI.changed) EditorUtility.SetDirty(reader); }
public override void OnInspectorGUI() { GUI.changed = false; //DrawDefaultInspector(); DialogueReader reader = (DialogueReader)target; reader.show[0] = EditorGUILayout.Foldout(reader.show[0], "General Settings"); if (reader.show[0]) { EditorGUI.indentLevel++; reader.mainTexture = (Texture2D)EditorGUILayout.ObjectField("Main Texture: ", reader.mainTexture, typeof(Texture2D), true); reader.widthStyle = (DialogueReader.SizeStyle)EditorGUILayout.EnumPopup("Width Style: ", reader.widthStyle); reader.heightStyle = (DialogueReader.SizeStyle)EditorGUILayout.EnumPopup("Height Style: ", reader.heightStyle); reader.nodeSize = EditorGUILayout.Vector2Field("Size: ", reader.nodeSize); reader.nodeBorder = EditorGUILayout.Vector2Field("Border: ", reader.nodeBorder); reader.defaultPosition = EditorGUILayout.Vector2Field("Default Position: ", reader.defaultPosition); reader.stickToEdges = EditorGUILayout.Toggle("Stick to Edges: ", reader.stickToEdges); EditorGUI.indentLevel--; } reader.show[1] = EditorGUILayout.Foldout(reader.show[1], "Content Settings"); if (reader.show[1]) { EditorGUI.indentLevel++; reader.displayName = EditorGUILayout.Toggle("Display Name: ", reader.displayName); reader.displayImage = EditorGUILayout.Toggle("Display Image: ", reader.displayImage); reader.imageSize = EditorGUILayout.IntField("Image Size: ", reader.imageSize); reader.textIndent = EditorGUILayout.IntField("Text Indent: ", reader.textIndent); reader.optionIndent = EditorGUILayout.IntField("Option Indent: ", reader.optionIndent); reader.alignment = (TextAnchor)EditorGUILayout.EnumPopup("Alignment: ", reader.alignment); reader.font = (Font)EditorGUILayout.ObjectField("Font: ", reader.font, typeof(Font), true); reader.fontColor = EditorGUILayout.ColorField("Font Color: ", reader.fontColor); reader.fontSize = EditorGUILayout.IntField("Font Size: ", reader.fontSize); EditorGUI.indentLevel--; } reader.show[2] = EditorGUILayout.Foldout(reader.show[2], "Highlight Settings"); if (reader.show[2]) { EditorGUI.indentLevel++; reader.highlightTexture = (Texture2D)EditorGUILayout.ObjectField("Highlight Texture: ", reader.highlightTexture, typeof(Texture2D), true); reader.stretchTexture = EditorGUILayout.Toggle("Stretch Texture: ", reader.stretchTexture); reader.highlightFontColor = EditorGUILayout.ColorField("Font Color: ", reader.highlightFontColor); EditorGUI.indentLevel--; } reader.show[3] = EditorGUILayout.Foldout(reader.show[3], "Extra Settings"); if (reader.show[3]) { EditorGUI.indentLevel++; reader.extraTexture = (Texture2D)EditorGUILayout.ObjectField("Extra Texture: ", reader.extraTexture, typeof(Texture2D), true); reader.extraSize = EditorGUILayout.Vector2Field("Extra Size: ", reader.extraSize); reader.extraPosition = EditorGUILayout.Vector2Field("Extra Offset: ", reader.extraPosition); EditorGUI.indentLevel--; } reader.show[4] = EditorGUILayout.Foldout(reader.show[4], "Sound Settings"); if (reader.show[4]) { EditorGUI.indentLevel++; reader.openNoise = (AudioClip)EditorGUILayout.ObjectField("Open Noise: ", reader.openNoise, typeof(AudioClip), true); reader.closeNoise = (AudioClip)EditorGUILayout.ObjectField("Close Noise: ", reader.closeNoise, typeof(AudioClip), true); reader.nextNoise = (AudioClip)EditorGUILayout.ObjectField("Next Noise: ", reader.nextNoise, typeof(AudioClip), true); reader.optionNoise = (AudioClip)EditorGUILayout.ObjectField("Option Noise: ", reader.optionNoise, typeof(AudioClip), true); EditorGUI.indentLevel--; } reader.show[5] = EditorGUILayout.Foldout(reader.show[5], "Demo Settings"); if (reader.show[5]) { EditorGUI.indentLevel++; reader.demo = EditorGUILayout.Toggle("Demo: ", reader.demo); reader.demoTalkDistance = EditorGUILayout.FloatField("Demo Talk Distance: ", reader.demoTalkDistance); reader.demoTalkWidth = EditorGUILayout.FloatField("Demo Talk Width: ", reader.demoTalkWidth); reader.demoGUIText = (GUIText)EditorGUILayout.ObjectField("Demo GUIText: ", reader.demoGUIText, typeof(GUIText), true); reader.demoGUIColor = EditorGUILayout.ColorField("Demo GUIColor ", reader.demoGUIColor); reader.show[6] = EditorGUILayout.Foldout(reader.show[6], "Custom Keys"); if (reader.show[6]) { EditorGUI.indentLevel++; reader.startKey = (KeyCode)EditorGUILayout.EnumPopup("Start Key: ", reader.startKey); reader.nextKey = (KeyCode)EditorGUILayout.EnumPopup("Next Key: ", reader.nextKey); reader.upKey = (KeyCode)EditorGUILayout.EnumPopup("Up Key: ", reader.upKey); reader.downKey = (KeyCode)EditorGUILayout.EnumPopup("Down Key: ", reader.downKey); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } if (GUILayout.Button("Edit Actors")) { ActorEditor.InitEditorWindow(reader); } if (GUILayout.Button("Edit Keys")) { KeyEditor.InitEditorWindow(reader); } if (GUI.changed) { EditorUtility.SetDirty(target); } }
//Draws properties panel - used to view properties of selected element void DrawProperties() { Rect propertyRect = new Rect(position.width - propertySize, 0, propertySize, position.height); GUI.Box(propertyRect, "", NewStyle("backgrounddark", 0, Color.black, FontStyle.Normal)); int spacer = 5; Rect propertyInnerRect = new Rect(position.width - propertySize + spacer, spacer, propertySize - spacer * 2, position.height - spacer * 2); GUI.Box(propertyInnerRect, "Properties", NewStyle("background", 20, Color.white, FontStyle.BoldAndItalic)); GUILayout.BeginArea(propertyInnerRect); GUILayout.Space(60); propertiesScroll = GUILayout.BeginScrollView(propertiesScroll); GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical(); if (selectedElement != null) { switch (selectedElement.GetType().ToString()) { case "Line": GUILayout.Label("Line", NewStyle("", 14, Color.white, FontStyle.Bold)); GUILayout.Space(20); (selectedElement as Line).text = GUILayout.TextArea((selectedElement as Line).text, GUILayout.MinHeight(60)); break; case "Option": GUILayout.Label("Option", NewStyle("", 14, Color.white, FontStyle.Bold)); GUILayout.Space(20); (selectedElement as Option).text = GUILayout.TextArea((selectedElement as Option).text, GUILayout.MinHeight(40)); break; case "Redirection": GUILayout.Label("Redirection", NewStyle("", 14, Color.white, FontStyle.Bold)); GUILayout.Space(20); (selectedElement as Redirection).automatic = EditorGUILayout.Toggle("Automatic: ", (selectedElement as Redirection).automatic); break; case "Action": GUILayout.Label("Action", NewStyle("", 14, Color.white, FontStyle.Bold)); GUILayout.Space(20); Action action = selectedElement as Action; action.name = EditorGUILayout.TextField("Key: ", action.name); action.operation = (Action.Operation)EditorGUILayout.EnumPopup("Action: ", action.operation); action.number = EditorGUILayout.IntField("Number: ", action.number); break; } DrawConditionsList(selectedElement.conditions); } else if (selectedNode != null && selectedNode.nodeID != 0) { GUILayout.Label("Node", NewStyle("", 14, Color.white, FontStyle.Bold)); GUILayout.Space(20); if (reader != null) { List <string> names = new List <string>(); names.Add("No Actor"); foreach (Actor actor in reader.actors) { names.Add(actor.name); } int index = reader.actors.FindIndex(x => x.actorID == selectedNode.actorID) + 1; index = EditorGUILayout.Popup(index, names.ToArray()); selectedNode.actorID = (index > 0) ? reader.actors[index - 1].actorID : 0; } else { EditorGUILayout.LabelField("No Dialogue Reader Found."); if (GUILayout.Button("Refresh")) { reader = (DialogueReader)GameObject.FindObjectOfType(typeof(DialogueReader)); } } } GUILayout.EndVertical(); GUILayout.Space(20); GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.EndArea(); }