言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Application.CancelQuit

public static function CancelQuit(): void;

Description

アプリケーションの終了を取り消します。これはゲーム終了時にスプラッシュスクリーンを表示するのに便利です。

この関数はプレイヤーでのみ動作するのでWebPlayerやEditor上では動作しません。 重要: この関数はiOS上では効果はありません。アプリケーションはiOS下では終了のキャンセルを行うことは出来ません。

	// Delays quitting for 2 seconds and
	// loads the finalsplash level during that time.

	var showSplashTimeout : float = 2.0;
	private var allowQuitting : boolean = false;

	function Awake () {
		// This game object needs to survive multiple levels
		DontDestroyOnLoad (this);
	}

	function OnApplicationQuit () {
		// If we haven't already load up the final splash screen level
		if (Application.loadedLevelName.ToLower() != "finalsplash")
			StartCoroutine("DelayedQuit");

		// Don't allow the user to exit until we got permission in
		if (!allowQuitting)
			Application.CancelQuit();
	}

	function DelayedQuit () {
		Application.LoadLevel("finalsplash");

		// Wait for showSplashTimeout
		yield WaitForSeconds(showSplashTimeout);

		// then quit for real
		allowQuitting = true;
		Application.Quit();
	}