Tag Archives: Setting the parent of a transform which resides in a Prefab Asset is…

Error: Setting the parent of a transform which resides in a Prefab Asset is…

Error log

Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption

Reason 1

Load a prefab with resouce. Load, and set the parent directly without instantiation. This leads to an error. The reason for the error is that the prefab without instantiation cannot directly operate transform, which will lead to data corruption

// Wrong
GameObject effect = Resource.Load("effect") as GameObject;
effect.transform.parent = transform;
// Right
GameObject effect = Instantiate(Resource.Load("effect")) as GameObject;
effect.transform.parent = transform;

Reason 2

If you drag something on pefab B to pefab a, you will get such an error