Hello, a fellow Unity use having time developing a basic clicker game,
And having an error of course!
I’m having this while loop in this coroutine, but it’s only repeating once!
It only running when the game starts, and here’s the edited Script:
private void Start()
{
DataController.Instance.LoadItemButton(this);
StartCoroutine("AddGoldLoop");
UpdateUI();
}
IEnumerator AddGoldLoop()
{
Debug.Log("AddGoldLoop");
while (true)
{
Debug.Log("WHILE");
if (isPurchased)
{
Debug.Log("ISPURCHASED");
DataController.Instance.gold += goldPerSecond;
StartCoroutine ("BG");
}
Debug.Log("IFEND");
yield return new WaitForSeconds(1.0f);
}
}
There is a problem in “AddGoldLoop()” and I can’t find out why.
Thanks for Answering my question!