///<summary> /// Main method for adding new dialogue to the queue ///</summary> public void AddDialogue(DialogueGroup dialogueGroup) { currentGroup = dialogueGroup; hasButtons = false; HideAllOptionButtons(); //Loop through all of the speakers and setup the queue foreach (DialogueSpeaker speaker in dialogueGroup.dialogueSpeakers) { Sprite sprite = speaker.sprite; string name = speaker.name; //Loop through all of the sentences foreach (string sentence in speaker.sentences) { DialogueData data = new DialogueData(); data.sprite = sprite; data.name = name; data.sentence = sentence; queue.Enqueue(data); } } //Startup for the first time if (IsDialoguePlaying == false) { IsDialoguePlaying = true; animator.SetBool("IsOpen", true); NextSentence(); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); DialogueData dataObject = (DialogueData)target; if (GUILayout.Button("Preview Audio")) { // Check there is audio? // Play on a dialogue manager with the target as object to play? } }
///<summary> /// Main method to call when to start the next sentence ///</summary> public void NextSentence() { //Has the dialogue ended? if (queue.Count <= 0) { EndDialogue(); return; } //Focus on the clickArea if (eventSystem) { eventSystem.SetSelectedGameObject(clickArea); } //Fetch the next data block DialogueData data = queue.Dequeue(); //Setup the name dialogueNameText.text = data.name; //Setup the sprite if (data.sprite != null) { imagePortrait.sprite = data.sprite; } else { imagePortrait.sprite = defaultPortrait; } //Setup the sentence string sentence = data.sentence; //Setup the buttons //Is this the last sentence if (queue.Count <= 0) { //Is there buttons to setup if (currentGroup.dialogueButtons != null && currentGroup.dialogueButtons.Count > 0) { hasButtons = true; SetupButtons(currentGroup.dialogueButtons); } } coroutineTyping = StartCoroutine(TypeSentence(sentence)); }