using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /// /// 底部栏界面 /// public class SwithPanel : MonoBehaviour { [SerializeField] private Button storeButton; [SerializeField] private Button drawingButton; [SerializeField] private Button shopButton; [SerializeField] private Button battleButton; [SerializeField] private List _gameObjects; // Start is called before the first frame update void Start() { } private void OnEnable() { storeButton.onClick.AddListener(StoreEvent); drawingButton.onClick.AddListener(DrawingEvent); shopButton.onClick.AddListener(ShopEvent); battleButton.onClick.AddListener(BattleEvent); } // Update is called once per frame void Update() { } private void OnDisable() { storeButton.onClick.RemoveListener(StoreEvent); drawingButton.onClick.RemoveListener(DrawingEvent); shopButton.onClick.RemoveListener(ShopEvent); battleButton.onClick.RemoveListener(BattleEvent); } private void StoreEvent() { SoundSystem.ins.ButtonEventAudio(); UIMgr.ins.OpenStorePanel(); } private void DrawingEvent() { SoundSystem.ins.ButtonEventAudio(); UIMgr.ins.OpenDrawingPanel(); } private void ShopEvent() { SoundSystem.ins.ButtonEventAudio(); UIMgr.ins.OpenForgePanel(); } private void BattleEvent() { SoundSystem.ins.ButtonEventAudio(); UIMgr.ins.OpenBattlePanel(); } public void SetIndex(int index) { foreach (var gameObject in _gameObjects) { gameObject.SetActive(false); } _gameObjects[index].SetActive(true); } }