- Home /
'Resource file has already been unloaded' error when exiting application in Editor
In my application, I'm doing the following:
Loading a scene file from an assetbundle (LoadBundle)
Setting the scene as my active scene (SceneManager.LoadScene)
Immediately unloading the assetbundle (Unload)
AssetBundle assetBundle = LoadBundle(scenePath + "build_scene.scene"); if (assetBundle == null) return; string sceneFullName = assetBundle.GetAllScenePaths().FirstOrDefault(); string sceneName = Path.GetFileNameWithoutExtension(sceneFullName); SceneManager.LoadScene(sceneName, LoadSceneMode.Single); assetBundle.Unload(false);
This code works as intended, but when I exit the application I get an error 'Resource file has already been unloaded', but only in the Editor. When I change the scene, export it and run the app again, the error will show up as many times as I've changed the scene. When I close the Editor and open it again, the error count resets. I'm not unloading any assets when closing my application, so it seems the Unity Editor is doing that itself, while holding onto some reference under the hood, inbetween plays even.
This error doesn't appear when running the application as a standalone player, but it's still rather annoying. I'd rather not have errors popping up constantly while developing. Does anyone know how to get rid of it?
Answer by Shotgunbunny · Nov 08, 2018 at 08:49 AM
I managed to get rid of the error by adding the line SceneManager.SetActiveSene
after LoadScene
.