I am working to develop a very simple inventory system. It consists of (currently) 5 buttons in a straight line with an image for each button, and what will be a counter on the side of each button as well. This part I have gotten successfully and I am proud of the basic work I have done, now I am having a bear of a time getting the next part to work.
I would like each of the buttons to represent a single item, like rocks, or wood, so the counters to the side show how many of a particular resource you have gathered. Currently I can not figure out how to link the buttons to the variables for each resource. I can gather 10 wood no problem, but I can’t display the 10 wood at all (although I do have a lovely GUI image).
This is my current code:
function OnGUI ()
{
GUI.skin = ResourceSkin;
if (ResourceOn == true)
{
GUI.BeginGroup(new Rect(0, 0, Screen.width, 30));
//Grid
GridValue = GUI.SelectionGrid(Rect(GridPosition.x, GridPosition.y, GridSize.x, GridSize.y), GridValue, Grids, NumberofButtons);
GUI.EndGroup();
}
}
I also have 5 variables much like this:
public var Wood = 0;
This current system gives me a few options in the inspector, Text, Image, and Tooltip. I set the grid to be 5 buttons, set each image to be the image of the resource I want, now I can’t figure out how to link them. It’s the last step and I’m so close, yet so far away. If anyone can offer any help at all, I would be greatly appreciative!
also for reference, I have been using this tutorial: