Unity UI prefab instantiation bug

43505-pic1.png

Where is the problem after instantiation it has different position and scale factor
GameCnt is a Canvas

![alt textvoid Generate() { GameObject objTR = Instantiate(Resources.Load("UI/Purple", typeof(GameObject)),Vector3.zero,Quaternion.identity) as GameObject; objTR.transform.localScale = Vector3.one; objTR.transform.SetParent(this.transform); }][2]

To avoid scaling problems when instantiating a new UI component and setting the parent you have to use SetParent() with the parameter worldPositionStays as false:

newInstance.transform.SetParent(original.transform.parent, false);

Instead of:

newInstance.transform.parent = original.transform.parent;

More information here: Redirect to... title of new-page