using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class InfraredResolution : MonoBehaviour
{
///
/// 建立Toggle列表,存取所有的Toggle,便于调用操作
///
[SerializeField] List ToggleList = new List();
// Start is called before the first frame update
int _index = 0;
void Start()
{
#if UNITY_ANDROID
if (InfraredDemo.running) {
_index = (int)InfraredDemo._ins.resoution.Get();
}
#endif
//给list赋值
//ToggleList = transform.GetComponentsInChildren().ToList();
//遍历Toggle Group下的所有Toggle
for (int i = 0; i < ToggleList.Count; i++)
{
var toggle = ToggleList[i];
var a = i;
toggle.isOn = _index == i;
//绑定Toggle事件
toggle.onValueChanged.AddListener(delegate (bool ison)
{
this.OnValueChanged(ison, a);
});
}
}
public void OnValueChanged(bool ison, int value)
{
if (ison)
{
print("执行你的选中方法:"+ value);
_index = value;
}
}
// Update is called once per frame
void Update()
{
}
public void Restart()
{
//存储一次操作数据
if (InfraredDemo.running) {
InfraredDemo._ins.resolutionRestartApp(_index);
Destroy(gameObject);
}
}
public void Close()
{
Destroy(gameObject);
}
}