Mysterious unaccessability to child gameobject

I try to be as simple and clear as I can:
I have a 3D model as a child of an empty game object. This model has been instantiated from the empty gameobject’s script. I tried to change material of this child, but nothing seemed to work. I tried to disable the renderer, nothing again. Last I started destroying these to see if I really access the right stuff. Ok, I destroy the parent, which worked and child was gone too. Then I tried to access and destroy the child and nothing happens. No errors, just nothing. I have no idea why this happens. Propably why I cannot do nothing with the materials either.

Empty game object has a private GameObject-field named prefabModel. It is instatiated this way:

private GameObject prefabModel;
. . .
Object obj = Resources.Load("path/to/model", typeof(GameObject));
prefabModel = Instantiate(obj, transform, false) as GameObject;

The way I try to access this child (p is the empty with the script mentioned just now):


I can print stuff this way no problem and destroy the parent with the child too:

print(p.transform.GetChild(0); // prints the name of child
Destroy(p.gameobject); // parent destroys fine and child gone too ofc

BUT NOW comes the interesting part:

Destroy(p.transform.GetChild(0).gameObject); // NOTHING HAPPENS!!!

I get no errors from this, nothing happens. So after this finding I made a method to the empty parent’s script (where the child is instantiated) to return the field:

public GameObject GetPrefabModel() {
        return prefabModel;

And now if i try to destroy the child:

Destroy(p.GetPrefabModel()); // Child is destoryed normally

I have not yet tried to change the materials of the object now that I have the GetPrefabModel()-function. But I will now after I have written this.

Can someone explain what exactly is going on with this? Maybe a bug with the GetChild()-function?

Or something funny the way I instantiate the child? (yes the child is in the hiearachy and gets destroyed along the parent too )

Not entirely sure why you are getting that error, however you need to keep in mind that everything you put it in the resources folder will ALWAYS get added to your final build and therefore should be kept as lean as possible since if you end up not using said object and leave it in there your loading unnecessary information to your final build.

you could try this setup instead:

public GameObject prefabModel; // drag into this position in inspector from your prefabs folder
GameObject child;
public bool test = false;  // in inspector make it true to test the destroy function.

void Start(){
child = p.transform.GetChild(0);

void Update(){


Check if that works.