Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1787 from petchema/throttled-unloadunusedassets
Do not call Resources.UnloadUnusedAssets() more than once every 3 mins
- Loading branch information
Showing
4 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Project: Daggerfall Tools For Unity | ||
// Copyright: Copyright (C) 2009-2020 Daggerfall Workshop | ||
// Web Site: http://www.dfworkshop.net | ||
// License: MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
// Source Code: https://github.com/Interkarma/daggerfall-unity | ||
// Original Author: Pango (petchema@concept-micro.com) | ||
// Contributors: | ||
// | ||
// Notes: | ||
// | ||
|
||
using System; | ||
using UnityEngine; | ||
|
||
namespace DaggerfallWorkshop | ||
{ | ||
public static class DaggerfallGC | ||
{ | ||
// Min time between two unused assets collections | ||
private const float uuaThrottleDelay = 180f; | ||
|
||
private static float uuaTimer = Time.realtimeSinceStartup; | ||
|
||
public static void ThrottledUnloadUnusedAssets() | ||
{ | ||
if (Time.realtimeSinceStartup >= uuaTimer) | ||
ForcedUnloadUnusedAssets(); | ||
} | ||
|
||
public static void ForcedUnloadUnusedAssets() | ||
{ | ||
Resources.UnloadUnusedAssets(); | ||
uuaTimer = Time.realtimeSinceStartup + uuaThrottleDelay; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters