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
Similar Posts:
- Unity – NullReferenceException: Object reference not set to an instance of an object
- Rigidbody.moveposition rigid body movement
- Failed to create agent because it is not close enough to the NavMesh
- [Solved] VS winsock.h and ws2def.h a large number of redefined error
- Unity3d: How to Change Font
- A brief summary of hash calculation in resource packaging of unity
- [Solved] TypeError: Cannot read properties of undefined (reading ‘templateName’)
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘configurationPropertiesBeans’ defined in class path resource
- Tag code error valueerror: bad input shape()
- Can’t find it“ android:Theme.Holo.Light.DarkActionBar ” [How to Solove]