Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Invoke() canceled, how?

Discussion in 'Scripting' started by Arcanor, Oct 23, 2014.

  1. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    283
    When I call Invoke("myFunc", 0.1f), it never calls myFunc (which is a private void function in the same class as the calling Invoke). How can this possibly be?

    When I call Invoke("myFunc", 0.0f), it works fine, albeit immediately, which I don't want. But at least this proves that the Invoke call and function name spelling are correct.

    OnDestroy() is not being triggered, so it's not because the object was deleted.

    I'm not calling CancelInvoke() except with an argument, and none of them in my project are CancelInvoke("myFunc").

    Is there any other way for an Invoke() to fail?
     
  2. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    283
    I've solved the problem at last. It turns out the Invoke() was not actually canceled at all, but still existant. The invoke call was used by my project to remove a progress bar loading screen. However, while the loading screen is up, I had paused the game using:
    Code (CSharp):
    1. Time.timeScale = 0.0f;
    Setting the time scale back to 1.0f solved the problem, and allowed my Invoke to proceed on schedule.