Hello guys,
I started making some UI prefabs to make my work easier. But something wrong happened when using the prefab. It’s how it looks like on the canvas I made the prefab (it fits the canvas):
There are underlying reasons this happened and you can track it down by examining everything about each scene’s canvas setup and scaling that are different from the other.
But keep in mind it might not be super-easily to address it in the general case, especially if you start partitioning your UI into chunks.
An alternate workflow is to put chunks of your UI into separate scenes and then load those scenes additively.
For instance you might have the following scenes, all loaded additively:
content scene (the level, including lighting)
player (including camera)
the generic UI (score, etc.) (including EventSystem)
the weapon UI (ammo, readout)
the pause UI (turned off until you press ESC)
the Inventory UI
etc.
By keeping those all as separate scenes, you can get away from lots of code to load prefab chunks here and there.
If you want your prefab to always match the parent’s size and shape, it’s probably better to set its anchors to stretch.
My best guess at what happened is that the resolution being used for your Game window in the editor changed, and the Canvas automatically changed to match it. (The exact manner of change will vary depending on the settings of your Canvas Scaler, if any.)