- Home /
Public Texture Variables Not Working
I'm creating an inventory-style series of GUI buttons that take items from a list and populate a window. The idea is that each button should use the texture specified in the public Texture variable for each one. However, it doesn't seem to work like I logically know it should.
for(int cnt = 0; cnt < player.Inventory.Count; cnt++)
if(GUI.Button(new Rect(240 + 105*cnt, 185, 75, 75), playerCharacter.Inventory[cnt].Icon))
...
After which point stuff happens. Player is a reference to an instance of class "Player", and Inventory is a List of a class called "Item", which acts as an umbrella for several classes that derive from it, which the items themselves inherit from (the Icon variable is inherited through all items by the base class, and is assigned individually). I get no errors from doing this, but it simply will not draw the Texture "Icon". I've tried a lot of increasingly annoying things, but nothing will get it to display. If I try to get another public variable such as Name or Cost, it displays fine.
I'm sure the answer is something inordinately stupid, but any help would be appreciated, I'm literally going crazy over this.
Your answer
Follow this Question
Related Questions
Can't initialise public vars in Inspector (C#) 2 Answers
Find + GetComponent not working as expected 0 Answers
Share Public Classes 1 Answer
Public variable not showing in Inspector(Solved) 1 Answer
Select colour then change texture 0 Answers