MonoBehaviour.OnDisable 当不可用

function OnDisable () : void

Description描述

This function is called when the behaviour becomes disabled () or inactive.

当对象变为不可用或非激活状态时此函数被调用。

This is also called when the object is destroyed and can be used for any cleanup code. When scripts are reloaded after compilation has finished, OnDisable will be called, followed by an OnEnable after the script has been loaded.

当物体被销毁时它将被调用,并且可用于任意清理代码。当脚本编译完成之后被重加载时,OnDisable将被调用,OnEnable在脚本被载入后调用。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnDisable() {
		print("script was removed");
	}
}
function OnDisable () {
	print("script was removed");
}

OnDisable cannot be a co-routine.

OnDisable不能用于协同程序。

Page last updated: 2011-7-20