MonoBehaviour.OnLevelWasLoaded 当关卡被加载

function OnLevelWasLoaded (level : int) : void

Description描述

This function is called after a new level was loaded.

当一个新关卡被载入时此函数被调用。

/level/ is the index of the level that was loaded. Use the menu item File->Build Settings... to see what scene the index refers to. See Also: Application.LoadLevel

/level/是被加载的关卡的索引。使用菜单项File->Build Settings... 来查看索引引用的是哪个场景。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnLevelWasLoaded(int level) {
		if (level == 13)
			print("Woohoo");

	}
}
// Prints "Woohoo" when level 13 is loaded.
// 当关卡13被加载时打印"Woohoo"
function OnLevelWasLoaded (level : int) {
	if (level == 13) {
		print ("Woohoo");
	}
}

OnLevelWasLoaded can be a co-routine, simply use the yield statement in the function.

OnLevelWasLoaded可以被用作协同程序,在函数中调用yield语句.

最后修改:2011年1月2日 Sunday 16:43

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。