I have set Application.wantsToQuit to trigger a method which will display a confirmation dialog. Only when pressed Yes, will the application actually quit. But NetworkManager doesn’t seem to care about that. The moment I press X, it’s over.
I tried asking chatgpt but it doesn’t have any solution for this. Has anyone else encountered this? How did you resolve it or worked your way around it?
Here’s my code:
private bool quitConfirmed = false;
private void OnEnable() => Application.wantsToQuit += QuitConfirmBox;
private void OnDisable() => Application.wantsToQuit -= QuitConfirmBox;
public void Quit() /* called by pressing YES when prompted */
{
quitConfirmed = true;
if (NetworkManager.Singleton != null) NetworkManager.Singleton.Shutdown();
Application.Quit();
}
private bool QuitConfirmBox()
{
uiManager.ConfirmQuitMessageBox();
return quitConfirmed;
}
private void OnApplicationQuit()
{
}
Removing the Shutdown calll from the code didn’t make any difference.