MainScenPanel.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Mono.UI.Core;
  2. using UnityEngine;
  3. using UnityEngine.SceneManagement;
  4. using UnityEngine.UI;
  5. namespace Mono
  6. {
  7. [UIBinding(prefab = "MainScenePanel")]
  8. public class MainScenePanel : UIPanel
  9. {
  10. public Button Btn_Home;
  11. public Button Btn_Visit;
  12. public Button Btn_My;
  13. public Button Btn_CSG;
  14. public Button Btn_Return;
  15. public override void GetUIData()
  16. {
  17. Btn_Home = UIData.Get<Button>("Btn_Home");
  18. Btn_Visit = UIData.Get<Button>("Btn_Visit");
  19. Btn_My = UIData.Get<Button>("Btn_My");
  20. Btn_CSG = UIData.Get<Button>("Btn_CSG");
  21. Btn_Return = UIData.Get<Button>("Btn_Return");
  22. }
  23. public override void AddButtonEvent()
  24. {
  25. Btn_Home.onClick.AddListener(() => { Debug.Log("点击家园"); });
  26. Btn_Visit.onClick.AddListener(() => { Debug.Log("点击游览"); });
  27. Btn_My.onClick.AddListener(() => { Debug.Log("点击我的"); });
  28. Btn_CSG.onClick.AddListener(() =>
  29. {
  30. SceneManager.LoadScene("dabaojian");
  31. UIManager.Instance.HideUIPanel<MainScenePanel>();
  32. TimeComponent.Instance.AddTimer(0.5f, () => { UIManager.Instance.LoadAndOpenPanel<TipPanel>(UIManager.UILayer.Middle); });
  33. });
  34. Btn_Return.onClick.AddListener(() =>
  35. {
  36. UIManager.Instance.StopBGM();
  37. UIManager.Instance.HideUIPanel<MainScenePanel>();
  38. UIManager.Instance.LoadAndOpenPanel<StartPanel>(UIManager.UILayer.Middle);
  39. UIManager.Instance.PlayAudioClip("UI_Close");
  40. });
  41. }
  42. public override void Show()
  43. {
  44. base.Show();
  45. UIManager.Instance.PlayBGM("scene01");
  46. }
  47. }
  48. }