UIManager.cs
1.71 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System.Collections;
using System.Collections.Generic;
using VIDE_Data;
using UnityEngine.UI;
using UnityEngine;
public class UIManager : MonoBehaviour
{
public GameObject container_NPC;
public GameObject container_PLAYER;
public Text text_NPC;
public Text text_PLAYER;
GameObject controller_R;
// Start is called before the first frame update
void Start()
{
container_NPC.SetActive(false);
container_PLAYER.SetActive(false);
controller_R = GameObject.Find("Controller (right)");
}
// Update is called once per frame
void Update()
{
if (controller_R.GetComponent<ActionTest>().GetTeleportDown())
{
if (!VD.isActive)
{
Begin();
}
else
{
VD.Next();
}
}
}
void Begin()
{
VD.OnNodeChange += UpdateUI;
VD.OnEnd += End;
VD.BeginDialogue(GetComponent<VIDE_Assign>());
}
void UpdateUI(VD.NodeData data)
{
container_NPC.SetActive(false);
container_PLAYER.SetActive(false);
if (data.isPlayer)
{
container_PLAYER.SetActive(true);
text_PLAYER.text = data.comments[data.commentIndex];
}
else
{
container_NPC.SetActive(true);
text_NPC.text = data.comments[data.commentIndex];
}
}
void End(VD.NodeData data)
{
container_NPC.SetActive(false);
container_PLAYER.SetActive(false);
VD.OnNodeChange -= UpdateUI;
VD.OnEnd -= End;
VD.EndDialogue();
}
void OnDisable()
{
if (container_NPC != null)
End(null);
}
}