Hey! I'm writing the script for my inventory.
What I'm trying to do is something like this:
function OnGUI()
{
GUILayout.BeginArea (Rect (0,0,400,));
GUILayout.BeginHorizontal();
if (hatchet > 0){
GUILayout.Button ("Hatchet");
}
if (coins > 0){
GUILayout.Button ("Coins");
}
if (logs > 0){
GUILayout.Button ("Logs");
}
if (kindling > 0){
GUILayout.Button ("Kindling");
}
if (fishingPole > 0){
GUILayout.Button ("Fishing Pole");
}
if (rawSalmon > 0){
GUILayout.Button ("Raw Salmon");
}
if (rawTrout > 0){
GUILayout.Button ("Raw Trout");
}
if (fishingBait > 0){
GUILayout.Button ("Fishing Bait");
}
if (cookedTrout > 0){
GUILayout.Button ("Cooked Trout");
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
This isn't my actual code. The buttons are more complicated and have functionality. But this is the basics of my inventory script. What I want is to have a 5 x 8 inventory where the buttons all align to the top and to the left. I don't want them overlapping. I think this could be achieved by writing script that automatically places:
GUILayout.EndHorizontal();
GUILayout.StartHorizontal();
after every 5 items that exist in the inventory (greater than 0). How could I do this?
Thanks very much.