Site icon Teaching Newbies since 2014

Unity3D Scripting API #11: OnApplicationPause() 📱

Unity3D Scripting API

Unity3D Scripting API

Unity Scripting API #11: OnApplicationPause() 📱

⭐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);
    }
}
Exit mobile version