Skip to main content
Unity3D

Unity3D Scripting API #11: OnApplicationPause() 📱

By February 5, 2021February 14th, 2021No Comments
Unity3D Scripting API
https://www.youtube.com/watch?v=UwIAlItv9JI&feature=youtu.be

⭐OnApplicationPause()

📱 Sent to all GameObjects when the application pauses.

📱 Called after OnEnable()if the script component is enabled ✅

📱 Called after Awake() if the script component is disabled ❌

📱 Called when an application goes to the background (true)

📱 Called when an application comes to the front (false)

📱 OnApplicationPause() takes a boolean (true or false) as an argument

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CubeController : MonoBehaviour
{
    // Start is called before the first frame update
    void Awake()
    {
        Debug.Log("Awake event");
    }
    void OnEnable()
    {
        Debug.Log("OnEnable event");
    }
    void Start()
    {
        Debug.Log("Start event");
    }

    void OnApplicationPause(bool pauseState)

    {
    Debug.Log("The application is paused: " + pauseState);
    }
}

Leave a Reply