12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
-
- using UnityEngine;
- using UnityEngine.UI;
- namespace Mono
- {
- [UIBinding(prefab = "StartPanel")]
- public class StartPanel : UIPanel
- {
- public Button Btn_Start;
- public Animator StartPanelAni;
- public override void GetUIData()
- {
- Btn_Start = UIData.Get<Button>(nameof(Btn_Start));
- StartPanelAni = UIData.Get<Animator>(nameof(StartPanelAni));
- }
- private float _timer;
- private bool _isEnable;
- public override void AddButtonEvent()
- {
- Btn_Start.onClick.AddListener(() =>
- {
- if (!_isEnable)
- {
- UIManager.Instance.PlayAudioClip("UI_Click");
- _isEnable = true;
- StartPanelAni.Play("starBtnOpen");
- }
- });
- }
- public void Update()
- {
- if (_isEnable)
- {
- _timer += Time.deltaTime;
- if (_timer >= 0.5f)
- {
- OpenMainScenePanel();
- _isEnable = false;
- _timer = 0;
- }
- }
- }
- public void OpenMainScenePanel()
- {
- UIManager.Instance.HideUIPanel<StartPanel>();
- UIManager.Instance.LoadAndOpenPanel<MainScenePanel>(UIManager.UILayer.Middle);
- }
- }
- }
|