- Home /
Destroying Component
private static void buffer()
{
gMenue = GameObject.Find("InterfaceBuffer").AddComponent<Menue>().GetComponent<Menue>();
}
private static void clearBuffer()
{
Destroy(gMenue);
}
I got this code (snippet from a class), and I just want to know, whether this only destroys the "Menue" component of the GameObject tagged as "InterfaceBuffer".
Thank you very much.
Answer by Mike 3 · Oct 25, 2010 at 08:00 PM
Yup, just the component itself
If you want to destroy the gameobject and everything on it, you'd want to destroy gMenue.gameObject
One small thing - AddComponent already returns a reference to your script, no need for the GetComponent too
Your answer
Follow this Question
Related Questions
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
Cannot destroy Component while GameObject is being activated or deactivated 2 Answers
Does Destroy() destroy all components? 2 Answers
Clearing a LineRenderer Whiteboard, so that you can start drawing again 1 Answer
Checking to see if there are no more of a certain object in the scene? 1 Answer