application.cancelquit 取消退出

2014-12-31 07:22| 发布者: 杨炎| 查看: 2269| 评论: 0|原作者: 蛮牛|来自: yzc88亚洲城脚本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 ();

}

相关阅读

文章点评
相关文章