Browse Source

- Set the assets to ignore the auto-unload by default. This favours performance by removing asset unloads over memory usage.
- Purge the assets prior to a new toy loadsing to removing any idle assets from any previously loaded toy.

MelvMay-GG 12 years ago
parent
commit
d84fdda
3 changed files with 9 additions and 2 deletions
  1. 4 0
      main.cs
  2. 1 1
      modules/Sandbox/1/scripts/scene.cs
  3. 4 1
      modules/Sandbox/1/scripts/toys.cs

+ 4 - 0
main.cs

@@ -49,6 +49,10 @@ ModuleDatabase.EchoInfo = false;
 // Set asset database information echo.
 AssetDatabase.EchoInfo = false;
 
+// Set the asset manager to ignore any auto-unload assets.
+// This cases assets to stay in memory unless assets are purged.
+AssetDatabase.IgnoreAutoUnload = true;
+
 // Scan modules.
 ModuleDatabase.scanModules( "modules" );
 

+ 1 - 1
modules/Sandbox/1/scripts/scene.cs

@@ -94,7 +94,7 @@ function destroySandboxScene()
         return;
 
     // Delete the scene.
-    SandboxScene.delete();         
+    SandboxScene.delete();
 }
 
 //-----------------------------------------------------------------------------

+ 4 - 1
modules/Sandbox/1/scripts/toys.cs

@@ -69,6 +69,9 @@ function loadToy( %moduleDefinition )
         
     // Create a sandbox scene.
     createSandboxScene();
+    
+    // Now is a good time to purge any idle assets.
+    AssetDatabase.purgeAssets();    
         
     // Set active toy.
     // This must be done here in-case a toy depends on it during its initialization.
@@ -105,5 +108,5 @@ function unloadToy()
     }
     
     // Reset active toy.
-    Sandbox.ActiveToy = "";     
+    Sandbox.ActiveToy = "";  
 }