Destroys a GameObject or Component, removing it from the scene and cleaning up resources. Calls onDisable() and onDestroy() lifecycle methods on all affected components.
onDisable()
onDestroy()
The Object3D or Component to destroy
If true (default), also destroys all children recursively
If true, also disposes GPU resources (geometries, materials, textures)
import { destroy } from "@needle-tools/engine";destroy(this.gameObject); Copy
import { destroy } from "@needle-tools/engine";destroy(this.gameObject);
destroy(myObject, true, true); // recursive + dispose GPU resources Copy
destroy(myObject, true, true); // recursive + dispose GPU resources
Destroys a GameObject or Component, removing it from the scene and cleaning up resources.
Calls
onDisable()andonDestroy()lifecycle methods on all affected components.