static function Destroy (obj : Object, t : float = 0.0F) : void Description描述
Removes a gameobject, component or asset.
删除一个游戏物体,组件或者资源。
The object obj will be destroyed now or if a time is specified t seconds from now. If obj is a Component it will remove the component from the GameObject and destroy it. If obj is a GameObject it will destroy the GameObject, all its components and all transform children of the GameObject. Actual object destruction is always delayed until after the current Update loop, but will always be done before rendering.
物体obj现在被销毁或在指定了t时间过后销毁。【狗刨学习网】
如果obj是组件,它将从GameObject销毁组件component。如果obj是GameObject 它将销毁GameObject全部它的组件和GameObject全部transform子物体。实际物体的销毁总是延迟到当前更新循环后,但总是渲染之前完成。
?C#
?JavaScript
// Kills the game object
//销毁游戏物体
Destroy (gameObject);
// Removes this script instance from the game object
//从游戏物体删除该脚本实例
Destroy (this);
// Removes the rigidbody from the game object
//从游戏物体删除刚体
Destroy (rigidbody);