1 using System.Collections;
2 using System.Collections.Generic;
6 public class Dialogue : MonoBehaviour
8 public GameObject continueButton;
9 public GameObject dialogueBox;
10 public GameObject SpeechBubble;
11 public GameObject mouse;
13 SpeechBubble speechBubble;
15 public Text dialogueText;
17 public string[] sentences;
20 public float typingSpeed;
24 dialogueBox.SetActive(false);
25 continueButton.SetActive(false);
26 SpeechBubble.SetActive(false);
27 speechBubble = SpeechBubble.GetComponent<SpeechBubble>();
32 if (dialogueText.text == sentences[index])
34 continueButton.SetActive(true);
38 public IEnumerator Type()
40 dialogueBox.SetActive(true);
41 speechBubble.NextSpeaker();
42 SpeechBubble.SetActive(true);
43 foreach (char letter in sentences[index].ToCharArray())
45 dialogueText.text += letter;
46 yield return new WaitForSeconds(typingSpeed);
50 public void NextSentence()
52 continueButton.SetActive(false);
54 if (index < sentences.Length - 1)
57 dialogueText.text = "";
58 StartCoroutine(Type());
59 speechBubble.NextSpeaker();
63 dialogueText.text = "";
64 dialogueBox.SetActive(false);
65 SpeechBubble.SetActive(false);
66 mouse.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;