-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubjectIDGUI.cs
51 lines (45 loc) · 1.33 KB
/
SubjectIDGUI.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SubjectIDGUI : MonoBehaviour
{
public Text txt_Label;
public Button bt_Go;
public InputField txt_ID;
private Canvas cv;
private string _participantID;
// Start is called before the first frame update
void Start()
{
cv = gameObject.GetComponent<Canvas>();
bt_Go.onClick.AddListener(OnGoClicked);
}
public void DisplayCompletionCode()
{
cv.enabled = true;
txt_Label.text = "Your completion code is: ";
txt_ID.text = _participantID;
txt_ID.enabled = false;
bt_Go.GetComponentInChildren<Text>().text = "Quit";
bt_Go.onClick.RemoveAllListeners();
bt_Go.onClick.AddListener(Quit);
}
private void Quit()
{
Application.Quit();
}
private void OnGoClicked()
{
string tmp_txt = txt_ID.text;
char[] reversed = new char[tmp_txt.Length];
for (int i = 0; i < tmp_txt.Length; i++)
{
reversed[i] = tmp_txt[tmp_txt.Length - 1 - i];
}
tmp_txt = Hash128.Compute(new string(reversed)).ToString();
_participantID = tmp_txt.Substring(tmp_txt.Length - 10, 10);
cv.enabled = false;
EventsController.instance.SendBegin();
}
}