Trading Company – Setting Up UI

I’m here to thrill you with another tale of the beauty of Game Development. As I mentioned in my last post about this Trading Company game, when I initially started, I foolishly dove in without giving much thought to format. From this I forgot to set Unity’s canvases to “Scale With Screen Size”, and so when I went back and actually did this it was a nightmare.

So once I changed the UI, everything was deformed, the screen was set to scale to the size of 1080×720. Everything was small and all over the place, all the panels were stretched and morphed. So first it took me a few hours wasting time fixing that, realigning everything so that it looked correct and didn’t freak out.

Then I had to actually upload this to my tablet, and see how it reacted there, because when transferring from my PC to the tablet also caused lots of positioning and scaling issues. The scaling of the UI was very different from PC to the tablet, and it took a lot of configuring to get it to all play nice together. Then the problem came with the UI that was being spawned in as prefabs.

There were quite a few sections in game where I am dynamically spawning in prefabs of UI objects. However, when they were spawned in they didn’t follow the canvas scaling size, and because of that they were either far too large or too small. It took me a few hours to actually find the solution; that when I instantiated the prefab, I have to manually set the parent with the optional boolean parameter set to false. This caused the screen scaling to be applied to the prefab.

Setting up the game is important, getting the features implemented is important; but getting it all setup correctly is more important. It will save you from a lot of pain and suffering as you try to eventually realize you have to set the parent of your UI correctly.

0 comments on “Trading Company – Setting Up UIAdd yours →

Leave a Reply

Your email address will not be published.