When I mean destroying itself, I do not mean for the script component to destroy a game object.
What I want is to call a script component to destroy the script component itself.
Here’s the following code:
public class Foo : MonoBehaviour {
public void Start() {
//Destroys Foo script component. And yes, Foo script component is "this piece of code," the code you are reading right now.
Destroy(this.GetComponent<Foo>());
}
}
How can it be done? I am having trouble destroying itself.