-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialogueSystem.cs
More file actions
58 lines (46 loc) · 1.21 KB
/
DialogueSystem.cs
File metadata and controls
58 lines (46 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class DialogueSystem : MonoBehaviour
{
public TextMeshProUGUI textDisplay;
public string[] sentences;
private int index;
public float speed;
public Sprite[] dibujos;
public SpriteRenderer dibujo;
public GameObject button;
public GameObject button2;
void Start()
{
StartCoroutine(Type());
}
IEnumerator Type()
{
yield return new WaitForSeconds(0.3f);
//Convert the text to separate letters and show it slowly
foreach (char letter in sentences[index].ToCharArray())
{
textDisplay.text += letter;
yield return new WaitForSeconds(speed);
}
}
public void Next()
{
if (index < sentences.Length - 1)
{
index++;
textDisplay.text = "";
dibujo.sprite = dibujos[index];
StartCoroutine(Type());
}
else
{
textDisplay.text = " ";
Destroy(button);
button2.SetActive(true);
}
}
}