General Design:
The inventory UI will be split into three sections. The items the player collects will be sub-categorised into four item classifications. An item will classified as consumable/merchant items, quest items, weapons and armour. Therefore the first section will allow the user to cycle through these sorted items.
Section two will concentrate on displaying and interacting with these categorised items. If the player selects to display weapons all weapons will be displayed within this area. The player can then browse through and interact with these items, whether it be to consume or equip one.
The final section will deal with player feedback; informing the player of the items purpose and in-game uses. It will hopefully give the player insight on the best time and benefits to using the item or whether it would be within their interest to sell the item.
All three sections will be displayed on the screen at once while the player has their inventory open, covering the entire screen. Each section will have it's own border to hopefully separate and inform the player each section serves it's open purpose.
UI Background Textures:
I have developed my UI textures with the colour scheme of brown which I will be using in conjunction with all other UI textures in my game from this point onward. This is the first draft design for the background textures of my inventory interface.
The aim is to add four buttons, equally spaced, and as large in height as the background, displayed horizontally across the top image. I will display the items in a list, each item occupying half the background's width, with up to 12 items per column, allowing for 24 items to displayed on top of the second image. I will use the third image to display easily readable text.
In order to assist with resolution differences I have created three sets for these images; a 360p, 720p and 1080p set. It is my hope that the textures will not appear distorted, regardless of resolution.
Adding the Background Textures:
I started my project by creating three scripts; 'Inventory.cs', responsible for drawing the inventory, 'StaticVariables.cs', responsible for informing the inventory when to draw and 'TextureBank.cs', responsible for loading in textures and their positions.
I always begin my projects by selecting a target resolution, the resolution I will develop my project in, which becomes the benchmark for how the project should be displayed. Logic dictates it's far simpler to scale around a resolution than attempt to develop for multiple resolutions.
I use a variable called 'screenMultiplier' to calculate texture pixel values. To my knowledge all screen resolutions are divisible by sixteen therefore I use this number as my multiplier. Using my target resolution I can calculate sixteen pixels for the screens width and height, which I set to the 'screenMultiplier'.
This allows for pixel perfect textures at my target resolution which will scale to look exactly the same on all resolutions.
To avoid texture distortion on images when there is a radical difference in screen size I change the textures loaded in depending on the screen size.
In order to ensure the 'TextureBank.cs' is loaded into the project before any other script, especially any script referencing it, I set the scripts execution order to the lowest value to ensure there are no problems.
All that's left is for the 'Inventory.cs' script to be able to gain access to the textures and display them. To gain access I must add the 'TextureBank.cs' script to a gameObject. This allows me to search the project for that gameObject and find a reference to the script by locating it as a component of the gameObject.
With the script reference I can get a reference to the textures and positions I need to be able to draw them to the UI. Assuming the player has their inventory open, which the 'StaticVariables.cs' will inform the 'Inventory.cs' script, I cycle through the background textures list and draw them, one by one, to the GUI.
There I have the first, small step, of my project achieved. It may not be anything significant yet but it proves the UI I am developing will scale nicely, without texture distortion, for multiple resolutions which is a nice platform to build from. See the results below...
360p Resolution
720p Resolution
1080p Resolution
Item Sorting Buttons:
There are four ways to sort my in-game items. An item can be a standard item pick up, such as consumable and merchant items, a weapon, such as a sword, to be equipped, wearable gear, such as armour and rings, and an important quest item.
Therefore the four buttons I need to design will contain the tags 'items', 'weapons', 'gear' and 'quest'. The player will be able to toggle through these buttons to display a sorted list of items which are sub-categorised into the item type they've selected. Each button must have three essential textures and an additional texture I choose to add.
The first of the three essential button textures is the original texture. This is the texture the button displays before the player interacts with it. In my game this will simply be the name of the button.
The second of the three essential button textures is the button selected texture. This is the texture the button will display when the button has been clicked. It feeds back to the player which option is currently selected and reaffirms the button click event was registered successfully.
The third of the three essential button textures is the buttons hover texture. This is the texture displayed when the player has their cursor over the button but hasn't clicked it. The purpose for this texture is to inform the player the button is clickable.
The fourth button which isn't essential but I choose to employ into my game is the hover texture combined with the selected texture. This texture is displayed when an option has been selected and the player has their cursor over the button. The reason I will add this is so the player can refresh the options list by re-clicking the button.
Button Designs:
The original button texture will just be the name, positioned in the centre of the background, with the text reprinted twice behind it, to achieve a three-dimensional effect. The colours of the reprinted text will be similar to the background colour to make it subtle but noticeable. The text is white to make it standout from the background more.
The selected button texture will contain the button name within the bounds of a box.
The hover button texture will contain an arrow, to the left of the text, pointing towards the text to inform the player that it's the button they are currently hovering over.
The final texture, the selected and hover textures, is a combination of the previous two textures.
Implementing the Buttons:
In order to implement the buttons into my project I must first add them into the texture bank. As I have shown previously how I add textures into my project I am not going to repeat myself here as the process is identical. Drawing the buttons however is slightly different so I will explain how I do this.
Having four button choices paints an interesting scenario as I need to differentiate the situations in which each button need be drawn. To help decipher this I have created my own enum value. An enum value is a custom variable I can use to set different states for a certain situation.
I have implemented the enum in order to keep track which button has been selected or whether none have been selected at all. The enum has five values to achieve this. The enum has to either be set to 'Unselected', 'Items', 'Weapons', 'Gear' and 'Quest'.
I used a succession of if else statements to determine which textures to draw for each option. For example if the 'Items' options has been selected I know the only texture I need drawn is either the selected or selected and hover button. I can then find the texture I need from the remaining two by checking if the button contains the mouse position. If true I draw the selected + hover button otherwise I draw the selected button.
If the items button hadn't been selected i'd have been left with a choice of the hover button texture or the original button texture. This again can be solved with a simply line of code checking if the button contains the mouse and drawing the appropriate texture depending on the results.
As you can see by the following image the results are what I would expect. The colour scheme, in my opinion, work well with the background texture and the white used stands out and is easily read.
The code executes perfectly and now I can begin working on the item database and sorting code. I will be documenting this section in another post and will continue this part of the blog when I am ready to begin drawing the sorted textures to the GUI.
Drawing the Items:
When the player selects an option I need to update the inventory to display it's specific objects. I retrieve the objects for the selected option by calling the corresponding sort method from the 'PlayerInventory' and store the returned list.
I'm easily able to loop through the list and draw them however I need to adjust the font height to fill the text area. The disadvantage of this technique is that the string may exceed the area width. I need to create a method to prevent overflow and then another to scroll the text.
I have pre-loaded four positions per line into the 'TextureBank' to display the textures icon, name, quantity and hover icon. If the mouse position is over the line position I will need to display the hover icon. If the player selects an item I need to draw a border around the item.

This code executes in a fairly similar manner to the sub categories therefore I will not go into detail about it.
Scrolling Text
Firstly, I need to determine if an item name exceeds it's area width and crop it to prevent unwanted overflow. I achieve this by converting the name to an array of characters, loop through the array and check if the characters, as far as the index, exceeds bounds. If the loop ends without exceeding the bounds width; the text fits within it's area therefore I can simply return the unedited name.
In order to scroll cropped text I need to create another method which executes whenever the player selects an item. This method acts almost identically except it returns a boolean and sets multiple class variable values. I initiate the string length, character overflow, starting index and set a boolean to determine the direction to scroll.
I use these values to retrieve a sub-string of the name between the start index and the string length. Increasing the start value will allow the items the appearance of scrolling. I do this within a method, executed within an invoke, repeated every .1 seconds.
This invoke will not stop unless an item is selected, the item is deselected, the category is changed or the inventory is closed.
Description
Displaying the description is similar to cropping the item names. It differs by return a list of strings instead of a singular string. Whenever the characters exceed it's area width I add the string to a list, store the split string index and keep going. This splits the entire description into multiple strings that will fit the description area perfectly.
Ideally, the description area would fit five strings therefore I set the text height to a font size that would accommodate it. I split the description into five positions minimum, increasing this number if the returned string count exceeds five.
I can then cycle through the amount of strings and draw them into the corresponding positions within the bounds.