-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButtonHandler.cs
66 lines (53 loc) · 1.79 KB
/
ButtonHandler.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
62
63
64
65
66
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ButtonHandler : MonoBehaviour
{
public Button btn;
public InputField songF;
public InputField melF;
public InputField chordF;
public InputField JSONF;
public InputField BPMF;
public InputField BPBF;
public static string songPath = "";
public static string melPath = "";
public static string chordPath = "";
public static string JSONPath = "";
public static int BPM;
public static int BPB;
void Start()
{
btn.onClick.AddListener(TaskOnClick);
}
public void TaskOnClick()
{
//Check if all fields are filled
if (songF.text.Trim().Length > 0 &&
melF.text.Trim('\"').Length > 0 &&
chordF.text.Trim().Length > 0 &&
JSONF.text.Trim().Length > 0 &&
BPMF.text.Trim().Length > 0 &&
BPBF.text.Trim().Length > 0)
{
char[] trimArr = {'\"', ' '}; //Characters to trim
//Set public fields
songPath = songF.text.Trim(trimArr);
melPath = melF.text.Trim(trimArr);
chordPath = chordF.text.Trim(trimArr);
JSONPath = JSONF.text.Trim(trimArr);
BPM = int.Parse(BPMF.text);
BPB = int.Parse(BPBF.text);
if (gameObject.GetComponentInChildren<Text>().text == "Data") SceneManager.LoadScene("TimeSyncScene");
if (gameObject.GetComponentInChildren<Text>().text == "Level") SceneManager.LoadScene("Levelv2Scene");
}
else
{
Debug.Log("Not all paths are given");
}
}
}