예제 #1
0
        public static void UnloadScene(Scene newScene)
        {
            SceneAssetsPackage difference = SceneManager.activeScene.assets.Difference(newScene.assets);

            // By finding the difference between the current scene and the newScene I am given a list of all the assets only found in the current scene,
            // which must all be unloaded, as they will no longer be used

            foreach (KeyValuePair <Type, List <string> > assets in difference.assets)
            {
                foreach (string asset in assets.Value)
                {
                    instance.resourceManagers[assets.Key].RemoveResource(asset);
                }
            }
        }