当前位置:   article > 正文

unity 项目强制退出通知服务器,MonoBehaviour.OnApplicationQuit() 当应用程序退出 - Unity5 中文 API 手册...

unity onapplicationquit

Description 描述

Sent to all game objects before the application is quit.

在应用退出之前发送给所有的游戏物体。

In the editor this is called when the user stops playmode. In the web player it is called when the web view is closed.

当用户停止运行模式时在编辑器中调用。当web被关闭时在网络播放器中被调用。

JavaScript:

function OnApplicationQuit() {

// Make sure prefs are saved before quitting.

PlayerPrefs.Save();

}

C#:

using UnityEngine;

using System.Collections;

public class ExampleClass : MonoBehaviour {

void OnApplicationQuit() {

PlayerPrefs.Save();

}

}

Note that iOS applications are usually suspended and do not quit. You should tick “Exit on Suspend” in Player settings for iOS builds to cause the game to quit and not suspend, otherwise you may not see this call. If “Exit on Suspend” is not ticked then you will see calls to OnApplicationPause instead.

注意,iOS程序通常暂停并不退出。你应该在Player settings中的iOS编译设置中选择Exit on Suspend(暂停时退出),这会使游戏退出并不会暂停,否则会看不到这个调用。如果Exit on Suspend不选择,应该使用OnApplicationPause替代。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/108114
推荐阅读
相关标签
  

闽ICP备14008679号