Invoke method does not work

Hi , so my invoke method dos not work
i have checked my spellings and they are all correct but as soon as i put reloadlevel into invoke , unity gives me a waring that the function is declared but never used , does anyone has a solution to this

             Invoke("ReloadLevel", 1f);

void ReloadLevel()


            int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;



Hi Parth,

Have you already tried to add Debug.Logs to your code to see what is going on during runtime? For example, you could add a Debug.Log to the default case to see if it gets executed. Add one before and after the Invoke method call.

See also:

Hey Nina ,

I have tried that if i use ReloadLevel in default it works perfectly fine but when i use invoke , game gives me this message Capture

Is this your whole code? Since the default case comes right before this method, there could be a problem with the code, e.g. the ReloadLevel method might be in the same code-block as the switch making it a local method. In that case, Invoke won’t work.

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

1 Like

i got it working , you were right i misplaced one of the brackets , thank you for your help :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms