You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Level05
|
|
{
|
|
public class ToggleRgister : MonoBehaviour
|
|
{
|
|
private GameObject[] imgs;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
imgs = new GameObject[transform.childCount];
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
imgs[i] = transform.GetChild(i).Find("selectedImg").gameObject;
|
|
}
|
|
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
int index = i;
|
|
Toggle toggle = null;
|
|
|
|
toggle = transform.GetChild(i).GetComponent<Toggle>();
|
|
if (toggle != null)
|
|
{
|
|
transform.GetChild(i).GetComponent<Toggle>().onValueChanged.AddListener((bool a) =>
|
|
{
|
|
AnswerSys.Instance.currentKey = index + 1;
|
|
for (int j = 0; j < imgs.Length; j++)
|
|
{
|
|
imgs[j].SetActive(false);
|
|
}
|
|
imgs[index].SetActive(true);
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|