/
DaggerfallGC.cs
36 lines (31 loc) · 1.03 KB
/
DaggerfallGC.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Project: Daggerfall Unity
// Copyright: Copyright (C) 2009-2023 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;
}
}
}