Sfoglia il codice sorgente

退出游戏提示框

beiguoxia 1 anno fa
parent
commit
7e113251d0

+ 13 - 2
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -1,6 +1,7 @@
 using UnityEngine;
 using ET;
 using static GFGGame.LauncherConfig;
+using System;
 
 namespace GFGGame
 {
@@ -343,11 +344,21 @@ namespace GFGGame
             ViewManager.Show<MainUIView>(null, null, true);
         }
 
-        public static void ShowExitAlert()
+        public static void ShowExitAlert(Action sureCallback = null)
         {
             AlertSystem.Show("我会想你的")
                     .SetLeftButton(true, "继续游戏")
-                    .SetRightButton(true, "退出游戏", (object data) => { Application.Quit(); });
+                    .SetRightButton(true, "退出游戏", (object data) => 
+                    { 
+                        if(sureCallback != null)
+                        {
+                            sureCallback.Invoke();
+                        }
+                        else
+                        {
+                            Application.Quit();
+                        }
+                    });
         }
     }
 }

+ 10 - 0
GameClient/Assets/Game/HotUpdate/HotUpdateDriver.cs

@@ -22,6 +22,7 @@ namespace GFGGame
         private void Update()
         {
             OperationSystem.Update();
+            CheckExitAlert();
         }
 
         private void OnDestroy()
@@ -33,5 +34,14 @@ namespace GFGGame
         {
             SQLiteHelper.Instance.CloseConnection(true);
         }
+
+        private void CheckExitAlert()
+        {
+            if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home))
+            {
+                QDManager.Exit();
+            }
+        }
+
     }
 }

+ 0 - 10
GameClient/Assets/Game/HotUpdate/Views/MainUI/MainUIView.cs

@@ -601,8 +601,6 @@ namespace GFGGame
 
         private void Update(object param)
         {
-            ShowExitAlert();
-
             UpdateActLuckyBox();
 
             UpdateLimitedActvityState();
@@ -693,14 +691,6 @@ namespace GFGGame
             }
         }
 
-        private void ShowExitAlert()
-        {
-            if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home))
-            {
-                QDManager.Exit();
-            }
-        }
-
         private void OnNumericChange(EventContext context)
         {
             var numericType = (int)context.data;