Delayed quit issue

Hi,

I want to call some methods after I hit stop in the editor.
I am using this code and “Waited” does not come in editor while “Check” does.
Looks like WaitForSeconds can´t be used here, right?
Any workaround?

    void OnApplicationQuit(){
        Application.CancelQuit();
        StartCoroutine("Delay");
    }

    IEnumerator Delay(){

        print("CHECK");
        yield return new WaitForSeconds(1.0f);
        print("WAITED");

        Application.Quit();
    }

You could use the EditorApplication.playmodeStateChanged callback to run code after the you stopped the game.
http://docs.unity3d.com/ScriptReference/EditorApplication-playmodeStateChanged.html

1 Like

Thanks, I had already tried this, but as a programmer newbie I didn´t get it running…