function OnDestroy () : void
Description描述
This function is called when the MonoBehaviour will be destroyed.
当MonoBehaviour将被销毁时,这个函数被调用。
OnDestroy will only be called on game objects that have previously been active.
OnDestroy只会在预先已经被激活的游戏物体上被调用。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void OnDestroy() {
print("Script was destroyed");
}
}
function OnDestroy () {
print("Script was destroyed");
}
OnDestroy cannot be a co-routine.
OnDestroy不能用于协同程序。