gold per sec Should use Invoke or Coroutine ?

I want to make Gold Per Sec Function. I am not sure about Invoke or Coroutine. I want best way for performance game.

Coroutine

I think the rule is that if it is a long running process. For example, in this, it would be expected to run for the entire time that the game is open. Then it should be a coroutine. Just make sure to not to:

yield return new WaitForSeconds(someTime);

every time you wait.
Create it and cache it.

private WaitForSeconds wait = new WaitForSeconds(0.1f);
2 Likes

Yes, that’s a very interesting point. I actually made a post on that topic, and I heavily tested 3 different Coroutine usage methods: https://forum.unity3d.com/threads/best-method-to-check-something-often-without-dragging-performance.444079/

1 Like