Skip to content

Commit

Permalink
feat: new mono behaviour callbacks added.
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-osipov committed Aug 26, 2020
1 parent 1a00a3c commit 61e84fc
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Runtime/Async/Coroutine/MonoBehaviourCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ public class MonoBehaviourCallback : MonoSingleton<MonoBehaviourCallback>
/// </summary>
public static event Action OnLateUpdate;

/// <summary>
/// In the editor this is called when the user stops playmode.
/// Learn more: [MonoBehaviour.OnApplicationQuit](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html)
/// </summary>
public static event Action ApplicationOnQuit;

/// <summary>
/// Sent to all GameObjects when the application pauses.
/// Learn more: [MonoBehaviour.OnApplicationPause](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationPause.html)
/// </summary>
public static event Action<bool> ApplicationOnPause;

/// <summary>
/// Sent to all GameObjects when the player gets or loses focus.
/// Learn more: [MonoBehaviour.OnApplicationFocus](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html)
/// </summary>
public static event Action<bool> ApplicationOnFocus;

/// <summary>
/// Frame-rate independent MonoBehaviour.FixedUpdate message for physics calculations.
/// Learn more: [MonoBehaviour.FixedUpdate](https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html)
Expand All @@ -34,5 +52,13 @@ public class MonoBehaviourCallback : MonoSingleton<MonoBehaviourCallback>
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();
}
}
}

0 comments on commit 61e84fc

Please sign in to comment.