using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; public class ChangePanel : MonoBehaviour { public Dropdown changeBtn; public List panels = new List(); // 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); } } }