TaiZhouChangChu/Assets/Script/LH/ChangePanel.cs

38 lines
776 B
C#

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class ChangePanel : MonoBehaviour
{
public Dropdown changeBtn;
public List<GameObject> panels = new List<GameObject>();
// Start is called before the first frame update
void Start()
{
changeBtn.onValueChanged.AddListener((int index) => { ShowOrHidePanel(index); });
}
// Update is called once per frame
void Update()
{
}
private void ShowOrHidePanel(int index)
{
for (int i = 0; i < panels.Count; i++)
{
panels[i].SetActive(false);
}
if (index < panels.Count)
{
panels[index].SetActive(true);
}
}
}