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 SpeechBubble.SetActive(false);
26 speechBubble = SpeechBubble.GetComponent<SpeechBubble>();
31 if (dialogueText.text == sentences[index])
33 continueButton.SetActive(true);
37 public IEnumerator Type()
39 dialogueBox.SetActive(true);
40 speechBubble.NextSpeaker();
41 SpeechBubble.SetActive(true);
42 foreach (char letter in sentences[index].ToCharArray())
44 dialogueText.text += letter;
45 yield return new WaitForSeconds(typingSpeed);
49 public void NextSentence()
51 continueButton.SetActive(false);
53 if (index < sentences.Length - 1)
56 dialogueText.text = "";
57 StartCoroutine(Type());
58 speechBubble.NextSpeaker();
62 dialogueText.text = "";
63 dialogueBox.SetActive(false);
64 SpeechBubble.SetActive(false);
65 mouse.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;