mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Clear texture cache on scene reload
This commit is contained in:
parent
7b4b949927
commit
aa0f9b6d8b
@ -135,6 +135,7 @@ namespace NewHorizons
|
||||
Logger.Log($"Scene Loaded: {scene.name} {mode}");
|
||||
|
||||
SearchUtilities.ClearCache();
|
||||
ImageUtilities.ClearCache();
|
||||
|
||||
_isChangingStarSystem = false;
|
||||
|
||||
|
||||
@ -143,11 +143,20 @@ namespace NewHorizons.Utility
|
||||
var texture = new Texture2D(2, 2);
|
||||
texture.name = Path.GetFileNameWithoutExtension(path);
|
||||
texture.LoadImage(data);
|
||||
UnityEngine.Object.DontDestroyOnLoad(texture);
|
||||
_loadedTextures.Add(path, texture);
|
||||
return texture;
|
||||
}
|
||||
|
||||
public static void ClearCache()
|
||||
{
|
||||
foreach(var texture in _loadedTextures.Values)
|
||||
{
|
||||
if (texture == null) continue;
|
||||
UnityEngine.Object.Destroy(texture);
|
||||
}
|
||||
_loadedTextures.Clear();
|
||||
}
|
||||
|
||||
public static Color GetAverageColor(Texture2D src)
|
||||
{
|
||||
var pixels = src.GetPixels32();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user