Problem with Destroy()

Okay, so I am making a custom editor game. There is a variable called “selectedObject”, that stands for the object that is currently selected and ready to be edited.

if (GUI.Button(Rect(135,215,100,20),"Delete")) {
Destroy(selectedObject);
}

And whenever I click the “Delete” button in game mode, to delete the selected object, I get this error… :frowning:

Can't remove component.
Can't remove Transform because MeshFilter, BoxCollider, MeshRenderer depends on it

Any ideas?

Destroy(selectedObject.gameObject);

destroy GameObject, if you want to destroy whole object. Transform is just a component that can’t be destroyed without GameObject