From b3204ac1bde63b0f7cbc9826aa50640efc118571 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 25 Jun 2014 13:33:23 +0100 Subject: [PATCH] Yield until unused assets have been unloaded --- Assets/Fungus/Scripts/SceneLoader.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/Fungus/Scripts/SceneLoader.cs b/Assets/Fungus/Scripts/SceneLoader.cs index bd3d7876..ef44f669 100644 --- a/Assets/Fungus/Scripts/SceneLoader.cs +++ b/Assets/Fungus/Scripts/SceneLoader.cs @@ -56,10 +56,11 @@ namespace Fungus Destroy(room.gameObject); } + // Wait for objects to actually be destroyed at end of run loop yield return new WaitForEndOfFrame(); - // Most big assets should no longer be referenced, so unload them. - Resources.UnloadUnusedAssets(); + // All Room assets should no longer be referenced now, so unload them. + yield return Resources.UnloadUnusedAssets(); // Wait until scene has finished downloading (WebPlayer only) while (!Application.CanStreamedLevelBeLoaded(sceneToLoad))