Teaching Newbies since 2014

kauress

  • Home
  • Javascript ❤
    • JavaScript
    • Node.js
  • WebDev Tuts
  • screencasts
  • Resources
  • VR & AR
  • Contact
  • Github
  • Twitter
  • YouTube
  • RSS
  • C++
You are here: Home / Unity3D / Unity3D Scripting API #11: OnApplicationPause() 📱

February 5, 2021 by: Kauress

Unity3D 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);
    }
}
Introduction to C# in Unity3D #5: Variables 📦
Unity3D Scripting API #12: OnApplicationFocus() 📱

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2021 ·Kauress