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.

33 lines
958 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
public class ToggleGroups : MonoBehaviour
{
[Header("题目索引")]
public int questionIndex;
[Header("正确答案")]
public int answer;
private void Start()
{
for (int i=0;i<GetComponentsInChildren<Toggle>().Length;i++) {
int index = i;
GetComponentsInChildren<Toggle>()[i].onValueChanged.AddListener((bool value)=> {
if (value) {
if (questionIndex == 0)
{
Level2Manager.Instance.YishiPanDuan(answer == index);
}
else if (questionIndex == 1)
{
Level2Manager.Instance.HuXiPanDuan(answer == index);
}
}
});
}
}
}