using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class ChildSwitchBtnPanel : MonoBehaviour { [Serializable] public class ChildSwitchBtnEvent : UnityEvent { public ChildSwitchBtnEvent() { } } [SerializeField] public ChildSwitchBtnEvent OnSwitchBtnClick; public GameObject _LastBtn; public GameObject _NextBtn; private int _TotalCount = 0; private static int _CurSelectIndex = 0; public void InitSwitchPanel(int totalCount, int curSelectIndex = 0) { _TotalCount = totalCount; _CurSelectIndex = curSelectIndex; if (totalCount == 0) { gameObject.SetActive(false); return; } _LastBtn.SetActive(_CurSelectIndex > 0); _NextBtn.SetActive(_CurSelectIndex < totalCount - 1); } public void OnSwithBtnClick(int index) { InitSwitchPanel(_TotalCount, _CurSelectIndex += index); if (OnSwitchBtnClick != null) OnSwitchBtnClick.Invoke(_CurSelectIndex); } }