voici mon script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DialogueManager : MonoBehaviour
{
public Text nameText;
public Text dialogueText;
private Queue sentences;
public static DialogueManager instance;
private void awake()
{
if(instance != null)
{
Debug.LogWarning("il y'a plus d'une instance dialogue manager dans la scene");
return;
}
instance = this;
sentences = new Queue();
}
public void StartDialogue(Dialogue dialogue)
{
nameText.text = dialogue.name;
sentences.Clear();
}
Foreach (string sentence, in dialogue.sentences)
{
sentences.Enqueue(sentence);
DisplayNextSentence();
}
void DisplayNextSentence()
{
if(sentences.Count == 0)
{
EndDialogue();
return;
}
string sentence = sentences.Dequeue();
dialogueText.text = sentence;
}
void EndDialogue()
{
Debug.Log("fin du dialogue");
}
}
↧