Unity - Scripting API - Object - Destroy
Unity - Scripting API - Object - Destroy
Destroy
unity.com
Search scripting...
MonoBehaviour
Motion Manual Object.Destroy
Scripting API
MovieTexture
Leave feedback
Network
Version: 2020.3 C#
SWITCH TO MANUAL
NetworkMessageInfo
NetworkPlayer
NetworkView Declaration
NetworkViewID public static void Destroy(Object obj,
float t = 0.0F);
Object
OcclusionArea
Parameters
OcclusionPortal
ParticleCollisionEvent obj The object to destroy.
ParticlePhysicsExtensions t The optional amount of time to delay
ParticleSystem before destroying the object.
ParticleSystemForceField
ParticleSystemRenderer Description
PatchExtents Removes a GameObject, component or asset.
PhysicMaterial
The object obj is destroyed immediately after the
Physics
current Update loop, or t seconds from now if a
Physics2D time is specified.
If obj is a Component, this
PhysicsJobOptions2D method removes the component from the
PhysicsMaterial2D GameObject and destroys it.
If obj is a
GameObject, it destroys the GameObject, all its
PhysicsScene
components and all transform children of the
PhysicsScene2D GameObject.
Actual object destruction is always
PhysicsSceneExtensions delayed until after the current Update loop, but is
always done before rendering.
using UnityEngine;
void DestroyGameObject()
Destroy(gameObject);
https://docs.unity3d.com/ScriptReference/Object.Destroy.html 1/3
30/8/2021 Unity - Scripting API: Object.Destroy
unity.com
void DestroyScriptInstance()
Search scripting... {
Network
Version: 2020.3 C#
{
NetworkMessageInfo
// Removes the rigidbody fro
NetworkPlayer Destroy(GetComponent<Rigidbo
NetworkView }
NetworkViewID
void DestroyObjectDelayed()
Object
{
ParticleCollisionEvent }
ParticlePhysicsExtensions
// When the user presses Ctrl, i
ParticleSystem // BoxCollider component from th
ParticleSystemForceField void Update()
ParticleSystemRenderer {
if (Input.GetButton("Fire1")
PatchExtents
{
PhysicMaterial Destroy(GetComponent<Box
Physics }
Physics2D }
PhysicsJobOptions2D
PhysicsMaterial2D
PhysicsScene
PhysicsScene2D Destroy is inherited from the UnityEngine.Object
PhysicsSceneExtensions base class.
https://docs.unity3d.com/ScriptReference/Object.Destroy.html 2/3
30/8/2021 Unity - Scripting API: Object.Destroy
Network
Version: 2020.3 C#
2021-08-23.
NetworkMessageInfo
NetworkPlayer Tutorials
Community Answers
Knowledge
NetworkView
Base
Forums
Asset Store
NetworkViewID
Object
OcclusionArea
OcclusionPortal
ParticleCollisionEvent
ParticlePhysicsExtensions
ParticleSystem
ParticleSystemForceField
ParticleSystemRenderer
PatchExtents
PhysicMaterial
Physics
Physics2D
PhysicsJobOptions2D
PhysicsMaterial2D
PhysicsScene
PhysicsScene2D
PhysicsSceneExtensions
https://docs.unity3d.com/ScriptReference/Object.Destroy.html 3/3