Skip to content

Commit a58103a

Browse files
author
wanderer
committed
增加OnApplicationPause,OnApplicationFocus的事件回调
1 parent 3fe5cb6 commit a58103a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Base/GameMode.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// <time> #2018年6月25日 12点06分# </time>
88
//-----------------------------------------------------------------------
99

10+
using System;
1011
using System.Collections;
1112
using System.Collections.Generic;
1213
using LitJson;
@@ -33,6 +34,7 @@ public partial class GameMode : MonoBehaviour
3334
public static DebuggerManager Debugger;
3435
public static ConfigManager Config;
3536
public static GameMode Self;
37+
3638

3739
#region 资源
3840
/// <summary>
@@ -66,6 +68,19 @@ public JsonData ConfigJsonData
6668
}
6769
#endregion
6870

71+
#region 回调
72+
/// <summary>
73+
/// 游戏进入后台时执行该方法 pause为true 切换回前台时pause为false
74+
/// 强制暂停时,先 OnApplicationPause
75+
/// </summary>
76+
public static Action<bool> OnAppPause;
77+
/// <summary>
78+
/// 游戏失去焦点也就是进入后台时 focus为false 切换回前台时 focus为true
79+
/// 重新“启动”手机时,OnApplicationFocus
80+
/// </summary>
81+
public static Action<bool> OnAppFocus;
82+
#endregion
83+
6984
#endregion
7085
IEnumerator Start()
7186
{
@@ -133,5 +148,15 @@ private void OnDestroy()
133148
GameFrameworkMode.ShutDown();
134149
}
135150

151+
private void OnApplicationPause(bool pause)
152+
{
153+
OnAppPause?.Invoke(pause);
154+
}
155+
156+
private void OnApplicationFocus(bool focus)
157+
{
158+
OnAppFocus?.Invoke(focus);
159+
}
160+
136161
}
137162
}

0 commit comments

Comments
 (0)