MonoBehaviour.OnLevelWasLoaded 当关卡被加载

function OnLevelWasLoaded (level : int) : void


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)

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


Page last updated: 2011-1-2