- Home /
Prefab to destroy
I know this is a newbie question but is it possible to destroy my prefab or make it dissapear after a few seconds it spawned?
/thanks
Answer by FLASHDENMARK · Apr 23, 2011 at 12:46 PM
You can use this for destroying the prefab:
And this for "hideing" the gameObject instead of destroying it:
GameObject.active = false; // For disableing
GameObject.active = true; // For enableing.
This will disable everything on the gameObject. Colliders, renderer, light you name it.
-Thanks to Bunny83.
Any questions please ask :)
Simple. It works but the collider will still be present when using renderer.enabled you are just unchecking the mesh renderer. 1+
Ohh, yeah that is right. I will update the post with a solution. Thanks. :)
How about setting GameObject.active to false? Prefabs can contain any GameObject. It doesn't need to have a renderer. It can have also a light, particleemitter, script, or any other component. If you disable the GameObject everything on this GameObject will be disabled.
I was actually not aware of that existing. But thanks I will edit the post with the suggestion you gave. Thank you :)
Your answer
Follow this Question
Related Questions
Destroy an instance of a prefab 1 Answer
Create a prefab at same position where its destroyed 3 Answers
How to destroy a game object within an instance of prefab 1 Answer
Instantiated Prefab doesnt destroy 2 Answers
Destroy a GameObject 2 Answers