お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closeアプリケーションが終了する前に全てのゲームオブジェクトで呼び出されます
エディタでは、ユーザが再生モードを停止したときに呼び出されます。 Webプレイヤーでは、Webビューが閉じられたとき呼び出されます。
function OnApplicationQuit() { // Make sure prefs are saved before quitting. PlayerPrefs.Save(); }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void OnApplicationQuit() { PlayerPrefs.Save(); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def OnApplicationQuit() as void: PlayerPrefs.Save()
iOS アプリケーションでは通常サスペンドされ、終了されないことに留意して下さい。 iOS ビルドにおいては Player settings で "Exit on Suspend" をチェックして、 ゲームをサスペンドせずに終了させることが出来きます。そうしない場合、 この呼び出しが行われない場合があります。 もし "Exit on Suspend" がチェックされてない場合、 代わりに OnApplicationPause が呼び出しされます。