I have a for loop that instantiates objects, that object has a script and I am giving that script an number.
My code looks like this:
void Update()
{
GameObject[] Clones = GameObject.FindGameObjectsWithTag("clone");
if (_UpgradesList.Count != UpgradesList.Count)
{
_UpgradesList.Clear();
foreach (Upgrades _upgrades in UpgradesList)
{
_UpgradesList.Add(_upgrades);
}
foreach (GameObject Clone in Clones)
{
Destroy(Clone);
}
for (int n = 4; n > -1; n--)
{
Debug.Log(n);
Instantiate(UpgradeButton, ParentObject);
UpgradeButton.tag = "clone";
UpgradeButton.GetComponent<UpgradeScript>().InternalListItem = n;
}
}
}
(The for loop at the bottom is the one)
I put a Debug.Log in the loop, but when I look in the console it says 0, 4, 3, 2, 1 and not 4, 3, 2, 1, 0