diff --git a/Runtime/Async/Coroutine/MonoBehaviourCallback.cs b/Runtime/Async/Coroutine/MonoBehaviourCallback.cs index 547533f..7b86f8a 100644 --- a/Runtime/Async/Coroutine/MonoBehaviourCallback.cs +++ b/Runtime/Async/Coroutine/MonoBehaviourCallback.cs @@ -25,6 +25,24 @@ public class MonoBehaviourCallback : MonoSingleton /// public static event Action OnLateUpdate; + /// + /// In the editor this is called when the user stops playmode. + /// Learn more: [MonoBehaviour.OnApplicationQuit](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html) + /// + public static event Action ApplicationOnQuit; + + /// + /// Sent to all GameObjects when the application pauses. + /// Learn more: [MonoBehaviour.OnApplicationPause](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationPause.html) + /// + public static event Action ApplicationOnPause; + + /// + /// Sent to all GameObjects when the player gets or loses focus. + /// Learn more: [MonoBehaviour.OnApplicationFocus](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html) + /// + public static event Action ApplicationOnFocus; + /// /// Frame-rate independent MonoBehaviour.FixedUpdate message for physics calculations. /// Learn more: [MonoBehaviour.FixedUpdate](https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html) @@ -34,5 +52,13 @@ public class MonoBehaviourCallback : MonoSingleton void Update() => OnUpdate?.Invoke(); void LateUpdate() => OnLateUpdate?.Invoke(); void FixedUpdate() => OnFixedUpdate?.Invoke(); + void OnApplicationPause(bool pauseStatus) => ApplicationOnPause?.Invoke(pauseStatus); + void OnApplicationFocus(bool hasFocus) => ApplicationOnFocus?.Invoke(hasFocus); + + protected override void OnApplicationQuit() + { + base.OnApplicationQuit(); + ApplicationOnQuit?.Invoke(); + } } }