Skip to content

Commit 61e84fc

Browse files
committed
feat: new mono behaviour callbacks added.
1 parent 1a00a3c commit 61e84fc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Runtime/Async/Coroutine/MonoBehaviourCallback.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ public class MonoBehaviourCallback : MonoSingleton<MonoBehaviourCallback>
2525
/// </summary>
2626
public static event Action OnLateUpdate;
2727

28+
/// <summary>
29+
/// In the editor this is called when the user stops playmode.
30+
/// Learn more: [MonoBehaviour.OnApplicationQuit](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html)
31+
/// </summary>
32+
public static event Action ApplicationOnQuit;
33+
34+
/// <summary>
35+
/// Sent to all GameObjects when the application pauses.
36+
/// Learn more: [MonoBehaviour.OnApplicationPause](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationPause.html)
37+
/// </summary>
38+
public static event Action<bool> ApplicationOnPause;
39+
40+
/// <summary>
41+
/// Sent to all GameObjects when the player gets or loses focus.
42+
/// Learn more: [MonoBehaviour.OnApplicationFocus](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html)
43+
/// </summary>
44+
public static event Action<bool> ApplicationOnFocus;
45+
2846
/// <summary>
2947
/// Frame-rate independent MonoBehaviour.FixedUpdate message for physics calculations.
3048
/// Learn more: [MonoBehaviour.FixedUpdate](https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html)
@@ -34,5 +52,13 @@ public class MonoBehaviourCallback : MonoSingleton<MonoBehaviourCallback>
3452
void Update() => OnUpdate?.Invoke();
3553
void LateUpdate() => OnLateUpdate?.Invoke();
3654
void FixedUpdate() => OnFixedUpdate?.Invoke();
55+
void OnApplicationPause(bool pauseStatus) => ApplicationOnPause?.Invoke(pauseStatus);
56+
void OnApplicationFocus(bool hasFocus) => ApplicationOnFocus?.Invoke(hasFocus);
57+
58+
protected override void OnApplicationQuit()
59+
{
60+
base.OnApplicationQuit();
61+
ApplicationOnQuit?.Invoke();
62+
}
3763
}
3864
}

0 commit comments

Comments
 (0)