- Home /
how make a for loop that makes GUI boxes ?
Hi i want to make a for loop that displays GUI boxes whatever the amount is
MyCode
public void LootAmountRandomizer()
{
LootAmount = Random.Range(0,100);
if(LootAmount<=50)
{
Debug.Log("3 items");
LootSlots = 3;
}
else if (LootAmount<=75)
{
Debug.Log("4 items");
LootSlots = 4;
}
else if(LootAmount<=90)
{
Debug.Log("5 items");
LootSlots = 5;
}
else if(LootAmount<=100)
{
Debug.Log("6 items");
LootSlots = 6;
}
}
Comment
Answer by ArkaneX · Nov 16, 2013 at 12:22 PM
Start with a sample code like the one below, and then tune it to your needs.
void OnGUI()
{
for(int i = 0; i < LootSlots; i++)
{
GUI.Box(new Rect(i * 40, 0, 40, 40), i.ToString());
}
}
Your answer
Follow this Question
Related Questions
GUI box problem? 0 Answers
my GUI.box is transparent 1 Answer
How to make spaces in between Gui boxes being made in for loops? 1 Answer
Where is my HP Bar? 3 Answers
Applying a script to multiple gui boxes 0 Answers