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语句.

Page last updated: 2011-1-2