What's wrong with this code? Whenever OnMouseDown is called unity freezes.
public class createTroops : MonoBehaviour {
public stats statsVars;
public GameObject prefab;
public int incPos = 4;
void OnMouseDown()
{
while (statsVars.units <= statsVars.units + statsVars.units)
{
Instantiate(prefab, new Vector3(-23.3f, 10 - incPos, 0), Quaternion.identity);
statsVars.units++;
}
if (statsVars.units >= statsVars.units + statsVars.units)
{
statsVars.units = 0;
}
}
}
↧