-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacterSelection.cs
62 lines (48 loc) · 1.4 KB
/
CharacterSelection.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
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class CharacterSelection : MonoBehaviour
{
private GameObject[] characterList;
private int index;
public void Start()
{
index = PlayerPrefs.GetInt("CharacterSelected");
if (index == null) {
index = 0;
}
characterList = new GameObject[transform.childCount];
for (int i = 0; i < transform.childCount; i++)
characterList[i] = transform.GetChild(i).gameObject;
foreach (GameObject go in characterList)
go.SetActive(false);
if (characterList[index])
characterList[index].SetActive(true);
}
public void ToggleLeft()
{
characterList[index].SetActive(false);
index--;
if (index < 0)
index = characterList.Length - 1;
characterList[index].SetActive(true);
}
public void ToggleRight()
{
characterList[index].SetActive(false);
index++;
if (index == characterList.Length)
index = characterList.Length - 1;
characterList[index].SetActive(true);
}
public void ConfirmButton()
{
PlayerPrefs.SetInt("CharacterSelected", index);
SceneManager.LoadScene("kindastable");
}
public void ExitButton()
{
index = 0;
SceneManager.LoadScene("shoeselection");
}
}