WXGame/Blacksmith/Assets/Script/UI/SwithPanel.cs

81 lines
1.8 KiB
C#
Raw Normal View History

2024-12-04 17:26:27 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 底部栏界面
/// </summary>
2024-12-04 17:26:27 +08:00
public class SwithPanel : MonoBehaviour
{
[SerializeField] private Button storeButton;
[SerializeField] private Button drawingButton;
[SerializeField] private Button shopButton;
[SerializeField] private Button battleButton;
2024-12-24 17:05:51 +08:00
[SerializeField] private List<GameObject> _gameObjects;
2024-12-04 17:26:27 +08:00
// Start is called before the first frame update
void Start()
{
}
private void OnEnable()
{
2024-12-16 17:25:10 +08:00
storeButton.onClick.AddListener(StoreEvent);
drawingButton.onClick.AddListener(DrawingEvent);
2024-12-04 17:26:27 +08:00
shopButton.onClick.AddListener(ShopEvent);
battleButton.onClick.AddListener(BattleEvent);
}
// Update is called once per frame
void Update()
{
}
private void OnDisable()
{
2024-12-16 17:25:10 +08:00
storeButton.onClick.RemoveListener(StoreEvent);
drawingButton.onClick.RemoveListener(DrawingEvent);
2024-12-04 17:26:27 +08:00
shopButton.onClick.RemoveListener(ShopEvent);
battleButton.onClick.RemoveListener(BattleEvent);
}
private void StoreEvent()
{
2024-12-26 11:39:49 +08:00
SoundSystem.ins.ButtonEventAudio();
2024-12-04 17:26:27 +08:00
UIMgr.ins.OpenStorePanel();
}
private void DrawingEvent()
{
2024-12-26 11:39:49 +08:00
SoundSystem.ins.ButtonEventAudio();
2024-12-04 17:26:27 +08:00
UIMgr.ins.OpenDrawingPanel();
}
private void ShopEvent()
{
2024-12-26 11:39:49 +08:00
SoundSystem.ins.ButtonEventAudio();
2024-12-04 17:26:27 +08:00
UIMgr.ins.OpenForgePanel();
}
private void BattleEvent()
{
2024-12-26 11:39:49 +08:00
SoundSystem.ins.ButtonEventAudio();
2024-12-04 17:26:27 +08:00
UIMgr.ins.OpenBattlePanel();
}
2024-12-24 17:05:51 +08:00
public void SetIndex(int index)
{
foreach (var gameObject in _gameObjects)
{
gameObject.SetActive(false);
}
_gameObjects[index].SetActive(true);
}
2024-12-04 17:26:27 +08:00
}