ScriptableObject.OnDisable 当禁用

function OnDisable () : void

Description描述

This function is called when the scriptable object goes out of scope

当可编写脚本对象超出范围时调用这个函数。

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");
}

OnEnable cannot be a co-routine.

OnDisable不能作为一个协同程序。

Page last updated: 2011-4-11