Tag Archives: Unity

New UI Prefab Scaling Solution

I recently changed the settings on my UI Canvas from “Screen Space – Overlay” to “Screen Space – Camera”. Which is how I’m sure it was supposed to be done in the first place (n00b here).

Anyway, in doing so, all of my UI prefabs were coming in scaled to 53.3333%.

I did a quick hack using a script to set those back to 1, but I figured there must be an elegant solution.

I finally found the (so, so simple) solution in the Unity forums.

When instantiating a prefab into the UI, you need to add the “false” argument when setting the parent.


GameObject obj = (GameObject)Instantiate (prefab);
obj.transform.SetParent (parent.transform, false);



GameObject obj = (GameObject)Instantiate (prefab);
obj.transform.SetParent (parent.transform);