找回密碼
 注冊帳號

掃一掃,訪問微社區

application.cancelquit 取消退出

2014-12-31 07:22| 發布者: 楊炎| 查看: 2689| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: application.cancelquit 取消退出static functioncancelquit() : voiddescription描述cancels quitting the application. this is useful for showing a splash screen at the end of a game.取消退出。這可以用來在 ...

application.cancelquit 取消退出

static functioncancelquit() : void

description描述

cancels quitting the application. this is useful for showing a splash screen at the end of a game.

取消退出。這可以用來在退出游戲的時候顯示一個退出畫面。

this function only works in the player and does nothing in the web player or editor. important: this function has no effect on iphone. application can not prevent termination under iphone os.

這個函數只工作在播發器中,在web播放器或編輯器中不做任何事。

注意,這個函數在iphone中沒有效果,應用程序無法防止在iphone os的終止。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

public float showsplashtimeout = 2.0f;

private bool allowquitting = false;

void awake() {

dontdestroyonload();

}

void onapplicationquit() {

if (application.loadedlevelname.tolower() != "finalsplash")

startcoroutine("delayedquit");

if (!allowquitting)

application.cancelquit();

}

ienumerator delayedquit() {

application.loadlevel("finalsplash");

yield return new waitforseconds(showsplashtimeout);

allowquitting = true;

application.quit();

}

}

// delays quitting for 2 seconds and

// 延遲2秒退出。

// 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

// 等待showsplashtimecout

yield waitforseconds (showsplashtimeout);

// then quit for real

// 然后退出

allowquitting = true;

application.quit ();

}

相關閱讀

文章點評
相關文章
女校游泳队彩金