Skip to main content
deleted 3 characters in body
Source Link
Jacksonkr
  • 259
  • 3
  • 16

I'm finding out that unity does not fully destroy all game objects on application quit. The result is that I have a number of async/await functionality that eventually runs and I can see output stream into the console long after the editor has been stopped.

Currently I'm manually disposing / destroying objects in OnApplicationQuit but this seems a bit silly.

Is there a more proper way to make sure all objects in the editor are fully destroyed on application quit ?

** EDIT **

How I'm using my async code

public static async Task<Texture2D> DownloadTexture(string uri)
{
    using (
        UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(uri, true)
    )
    {
        var asyncOp = uwr.SendWebRequest();

        if (WeatherTracker.instance == null)
        {
            uwr.Abort(); // todo: something related to this is crashing the editor while textures are still being download @jkr
            return null;
        }
        while (asyncOp.isDone == false)
        await Task.Delay(1000 / MainCamera.instance.MaxFrameRate);

        // return this.uwr.SendWebRequest();
        // Debug.Log($"download tex {z}/{x}/{y}");
        if (uwr.result != UnityWebRequest.Result.Success)
        {
            Debug.LogError($"{uwr.error}: {uri}");
            return null;
        }
        else
        {
            return DownloadHandlerTexture.GetContent(uwr);
        }
    }
}

I'm finding out that unity does not fully destroy all game objects on application quit. The result is that I have a number of async/await functionality that eventually runs and I can see output stream into the console long after the editor has been stopped.

Currently I'm manually disposing / destroying objects in OnApplicationQuit but this seems a bit silly.

Is there a more proper way to make sure all objects in the editor are fully destroyed on application quit ?

** EDIT **

How I'm using my async code

public static async Task<Texture2D> DownloadTexture(string uri)
{
    using (
        UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(uri, true)
    )
    {
        var asyncOp = uwr.SendWebRequest();

        if (WeatherTracker.instance == null)
        {
            uwr.Abort(); // todo: something related to this is crashing the editor while textures are still being download @jkr
            return null;
        }
        while (asyncOp.isDone == false)
        await Task.Delay(1000 / MainCamera.instance.MaxFrameRate);

        // return this.uwr.SendWebRequest();
        // Debug.Log($"download tex {z}/{x}/{y}");
        if (uwr.result != UnityWebRequest.Result.Success)
        {
            Debug.LogError($"{uwr.error}: {uri}");
            return null;
        }
        else
        {
            return DownloadHandlerTexture.GetContent(uwr);
        }
    }
}

I'm finding out that unity does not fully destroy all game objects on application quit. The result is that I have a number of async/await functionality that eventually runs and I can see output stream into the console long after the editor has been stopped.

Currently I'm manually disposing / destroying objects in OnApplicationQuit but this seems a bit silly.

Is there a more proper way to make sure all objects in the editor are fully destroyed on application quit ?

** EDIT **

How I'm using async code

public static async Task<Texture2D> DownloadTexture(string uri)
{
    using (
        UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(uri, true)
    )
    {
        var asyncOp = uwr.SendWebRequest();

        if (WeatherTracker.instance == null)
        {
            uwr.Abort(); // todo: something related to this is crashing the editor while textures are still being download @jkr
            return null;
        }
        while (asyncOp.isDone == false)
        await Task.Delay(1000 / MainCamera.instance.MaxFrameRate);

        // return this.uwr.SendWebRequest();
        // Debug.Log($"download tex {z}/{x}/{y}");
        if (uwr.result != UnityWebRequest.Result.Success)
        {
            Debug.LogError($"{uwr.error}: {uri}");
            return null;
        }
        else
        {
            return DownloadHandlerTexture.GetContent(uwr);
        }
    }
}
adding async code to the question
Source Link
Jacksonkr
  • 259
  • 3
  • 16

I'm finding out that unity does not fully destroy all game objects on application quit. The result is that I have a number of async/await functionality that eventually runs and I can see output stream into the console long after the editor has been stopped.

Currently I'm manually disposing / destroying objects in OnApplicationQuit but this seems a bit silly.

Is there a more proper way to make sure all objects in the editor are fully destroyed on application quit ?

** EDIT **

How I'm using my async code

public static async Task<Texture2D> DownloadTexture(string uri)
{
    using (
        UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(uri, true)
    )
    {
        var asyncOp = uwr.SendWebRequest();

        if (WeatherTracker.instance == null)
        {
            uwr.Abort(); // todo: something related to this is crashing the editor while textures are still being download @jkr
            return null;
        }
        while (asyncOp.isDone == false)
        await Task.Delay(1000 / MainCamera.instance.MaxFrameRate);

        // return this.uwr.SendWebRequest();
        // Debug.Log($"download tex {z}/{x}/{y}");
        if (uwr.result != UnityWebRequest.Result.Success)
        {
            Debug.LogError($"{uwr.error}: {uri}");
            return null;
        }
        else
        {
            return DownloadHandlerTexture.GetContent(uwr);
        }
    }
}

I'm finding out that unity does not fully destroy all game objects on application quit. The result is that I have a number of async/await functionality that eventually runs and I can see output stream into the console long after the editor has been stopped.

Currently I'm manually disposing / destroying objects in OnApplicationQuit but this seems a bit silly.

Is there a more proper way to make sure all objects in the editor are fully destroyed on application quit ?

I'm finding out that unity does not fully destroy all game objects on application quit. The result is that I have a number of async/await functionality that eventually runs and I can see output stream into the console long after the editor has been stopped.

Currently I'm manually disposing / destroying objects in OnApplicationQuit but this seems a bit silly.

Is there a more proper way to make sure all objects in the editor are fully destroyed on application quit ?

** EDIT **

How I'm using my async code

public static async Task<Texture2D> DownloadTexture(string uri)
{
    using (
        UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(uri, true)
    )
    {
        var asyncOp = uwr.SendWebRequest();

        if (WeatherTracker.instance == null)
        {
            uwr.Abort(); // todo: something related to this is crashing the editor while textures are still being download @jkr
            return null;
        }
        while (asyncOp.isDone == false)
        await Task.Delay(1000 / MainCamera.instance.MaxFrameRate);

        // return this.uwr.SendWebRequest();
        // Debug.Log($"download tex {z}/{x}/{y}");
        if (uwr.result != UnityWebRequest.Result.Success)
        {
            Debug.LogError($"{uwr.error}: {uri}");
            return null;
        }
        else
        {
            return DownloadHandlerTexture.GetContent(uwr);
        }
    }
}
Source Link
Jacksonkr
  • 259
  • 3
  • 16

Unity does not kill everything on application quit

I'm finding out that unity does not fully destroy all game objects on application quit. The result is that I have a number of async/await functionality that eventually runs and I can see output stream into the console long after the editor has been stopped.

Currently I'm manually disposing / destroying objects in OnApplicationQuit but this seems a bit silly.

Is there a more proper way to make sure all objects in the editor are fully destroyed on application quit ?