StartPanel.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. namespace Mono
  5. {
  6. [UIBinding(prefab = "StartPanel")]
  7. public class StartPanel : UIPanel
  8. {
  9. public Button Btn_Start;
  10. public Animator StartPanelAni;
  11. public override void GetUIData()
  12. {
  13. Btn_Start = UIData.Get<Button>(nameof(Btn_Start));
  14. StartPanelAni = UIData.Get<Animator>(nameof(StartPanelAni));
  15. }
  16. private float _timer;
  17. private bool _isEnable;
  18. public override void AddButtonEvent()
  19. {
  20. Btn_Start.onClick.AddListener(() =>
  21. {
  22. if (!_isEnable)
  23. {
  24. UIManager.Instance.PlayAudioClip("UI_Click");
  25. _isEnable = true;
  26. StartPanelAni.Play("starBtnOpen");
  27. }
  28. });
  29. }
  30. public void Update()
  31. {
  32. if (_isEnable)
  33. {
  34. _timer += Time.deltaTime;
  35. if (_timer >= 0.5f)
  36. {
  37. OpenMainScenePanel();
  38. _isEnable = false;
  39. _timer = 0;
  40. }
  41. }
  42. }
  43. public void OpenMainScenePanel()
  44. {
  45. UIManager.Instance.HideUIPanel<StartPanel>();
  46. UIManager.Instance.LoadAndOpenPanel<MainScenePanel>(UIManager.UILayer.Middle);
  47. }
  48. }
  49. }