After I finished work getting the Inventory UI finished, as well as the tool tips, I immediately was thinking that it was just too damned large. As I started making changes, I realized how annoying it was to do it. I had to change the width/height of the main panel, the inventory slots panel, each slot, and each image within the slot. Also, another thought arose. What if I wanted to make this a little more generic, and use it in different places in the game? It was clear to me that I need to be a little more smart about how these settings were used, and come up with a solution to make the creation of them a little more dynamic.

Luckily, by default, Unity already has an existing way to set certain fields from within the editor itself. I just needed to expose them. All I would end up needing are the following fields:

  • number of rows
  • number of columns
  • tile slot resolution (current just a square)

You can see those exposed settings below:

Being able to set the values of fields from within the editor is great.

Underneath it all, I of course had to implement the logic to determines how to draw the inventory UI, but I won’t bore you with all the…, well, boring details… The end results is that I’m able to now achieve the following straight from the editor:

Another benefit of this is when dealing with different screen resolutions… Maybe… I haven’t spent too much time worrying about that, but if I need to dynamically scale certain UI elements, this will be ready. Another thought is that, say I wanted to introduce a hot bar on the bottom of the screen… I could just set the rows to 1, and boom, we’re good to go!

Next up is drag and drop functionality! Should be fun to implement.

Till tomorrow…