MenuForm.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 Jiang Yin. All rights reserved.
  4. // Homepage: https://gameframework.cn/
  5. // Feedback: mailto:ellan@gameframework.cn
  6. //------------------------------------------------------------
  7. using UnityEngine;
  8. using UnityGameFramework.Runtime;
  9. namespace MetaClient
  10. {
  11. public class MenuForm : UGuiForm
  12. {
  13. [SerializeField]
  14. private GameObject m_QuitButton = null;
  15. private ProcedureMenu m_ProcedureMenu = null;
  16. public void OnStartButtonClick()
  17. {
  18. m_ProcedureMenu.StartGame();
  19. }
  20. public void OnSettingButtonClick()
  21. {
  22. GameEntry.UI.OpenUIForm(UIFormId.SettingForm);
  23. }
  24. public void OnAboutButtonClick()
  25. {
  26. GameEntry.UI.OpenUIForm(UIFormId.AboutForm);
  27. }
  28. public void OnQuitButtonClick()
  29. {
  30. GameEntry.UI.OpenDialog(new DialogParams()
  31. {
  32. Mode = 2,
  33. Title = GameEntry.Localization.GetString("AskQuitGame.Title"),
  34. Message = GameEntry.Localization.GetString("AskQuitGame.Message"),
  35. OnClickConfirm = delegate (object userData) { UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Quit); },
  36. });
  37. }
  38. #if UNITY_2017_3_OR_NEWER
  39. protected override void OnOpen(object userData)
  40. #else
  41. protected internal override void OnOpen(object userData)
  42. #endif
  43. {
  44. base.OnOpen(userData);
  45. m_ProcedureMenu = (ProcedureMenu)userData;
  46. if (m_ProcedureMenu == null)
  47. {
  48. Log.Warning("ProcedureMenu is invalid when open MenuForm.");
  49. return;
  50. }
  51. m_QuitButton.SetActive(Application.platform != RuntimePlatform.IPhonePlayer);
  52. }
  53. #if UNITY_2017_3_OR_NEWER
  54. protected override void OnClose(bool isShutdown, object userData)
  55. #else
  56. protected internal override void OnClose(bool isShutdown, object userData)
  57. #endif
  58. {
  59. m_ProcedureMenu = null;
  60. base.OnClose(isShutdown, userData);
  61. }
  62. }
  63. }