using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ToggleChooser : MonoBehaviour
{
[SerializeField]
private Toggle[] leftToggles;
[SerializeField]
private GameObject[] rightChoosers;
void Start()
{
SetAllRightChooserNotActive();
rightChoosers[0].SetActive(true);
for (int i = 0; i < leftToggles.Length; ++i)
{
if (leftToggles.Length <= 0)
break;
else
{
int idx = i;
leftToggles[i].onValueChanged.AddListener(delegate(bool isOn)
{
this.OnValueChanged(isOn, idx);
});
}
}
}
private void OnValueChanged(bool isOn, int index)
{
if (rightChoosers.Length > 0)
{
SetAllRightChooserNotActive();
switch (index)
{
case 0:
rightChoosers[0].SetActive(true);
break;
case 1:
rightChoosers[1].SetActive(true);
break;
case 2:
rightChoosers[2].SetActive(true);
break;
case 3:
rightChoosers[3].SetActive(true);
break;
default:
break;
}
}
}
private void SetAllRightChooserNotActive()
{
if (rightChoosers.Length > 0)
{
for (int i = 0; i < rightChoosers.Length; ++i)
{
if (rightChoosers[i].activeSelf)
{
rightChoosers[i].SetActive(false);
}
}
}
}
}