- Home /
Assigning a GUIStyle with a String Variable?
Hey, I'm working on my RPG and currently trying to make this inventory work. It actually operates fine, but the code for just one inventory slot is too long and sloppy. Mainly because I'm using a very long switch syntax for every item in the game which must be included on all of 36 Inventory Slots! So, I wanted to make the icon of the Inventory Slot change through a function that returns a string variable for the current item in the slot the user has activated. I want to make the GUIStyle the string variable set to the slot. For ex: if(GUI.Button(Rect(5, 5, 5, 5), "", InventorySlot1))
InventorySlot1 Represents a String variable which holds the name of the item that is supposed to be in that slot. I named my GUIStyles accordingly. Where, if the item and the string var names are = "Potion" the GUISkin name is also = "Potion". However, this gives me an error: "Unable to find style 'Potion' in skin 'GameSkin' Repaint". I Really thought that this would be a good idea and would save me a lot of time and clean up my code. Please help, Thanks :)
Your answer
Follow this Question
Related Questions
Real Simple Inventory and Vendor System Help 1 Answer
Inventory Help 0 Answers
How to select a texture in an inventory? 0 Answers
how make a for loop that makes GUI boxes ? 1 Answer
GUI Button to create another GUI 1 Answer