赞
踩
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替代。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。