-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCanvas.cs
61 lines (59 loc) · 1.85 KB
/
Canvas.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Canvas : MonoBehaviour {
TextMesh text;
public float letterPause = 0.00001f;
string msg = "";
TextMesh textdrama;
TextMesh texthunt;
TextMesh textart;
// Use this for initialization
void Start () {
textdrama = GameObject.Find("Canvas/DramaText").GetComponent<TextMesh>();
texthunt = GameObject.Find("Canvas/HuntText").GetComponent<TextMesh>();
textart = GameObject.Find("Canvas/ArtText").GetComponent<TextMesh>();
texthunt.gameObject.SetActive(false);
textdrama.gameObject.SetActive(false);
textart.gameObject.SetActive(false);
}
IEnumerator Type()
{
foreach (char letter in msg.ToCharArray())
{
text.text += letter;
if (text.text == msg)
{
text.text = "";
}
yield return new WaitForSeconds(letterPause);
}
}
// Update is called once per frame
void Update()
{
string nearest = GameObject.Find("First Person Controller").GetComponent<Move>().getNearestBuilding();
if (nearest != null && Input.GetKeyDown("i"))
{
if (nearest == "Drama")
{
text = textdrama;
textdrama.gameObject.SetActive(true);
}
else if (nearest == "Hunt Library")
{
text = texthunt;
texthunt.gameObject.SetActive(true);
}
else if (nearest == "CFA")
{
text = textart;
textart.gameObject.SetActive(true);
}
msg = text.text;
text.text = "";
StartCoroutine(Type());
}
}
}