From fe776be7f1e68d314a6ba92656e14fd5a4468804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Schm=C3=B6cker?= Date: Tue, 31 Oct 2023 11:28:17 +0100 Subject: [PATCH] feat: added sprite cache revision --- CHANGELOG.md | 1 + JotunnLib/Managers/RenderManager.cs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab83270b9..434dd7f26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Fixed the debug mode Jötunn ASCII art * Fixed AddComponentCopy was setting the name and tag of the Component's GameObject * Fixed KeyHints for left hand items +* Fixed sprite rendering results in mostly empty sprites in Unity 2022, backwards compatible and an existing cached sprite will be recreated ## Version 2.14.5 * Fixed GUIManager assets not being properly initialized when later accessed, causing some elements to not show up diff --git a/JotunnLib/Managers/RenderManager.cs b/JotunnLib/Managers/RenderManager.cs index d3bfb2b6b..e2db09eb4 100644 --- a/JotunnLib/Managers/RenderManager.cs +++ b/JotunnLib/Managers/RenderManager.cs @@ -23,6 +23,11 @@ public class RenderManager : IManager private static RenderManager _instance; private Sprite EmptySprite { get; } = Sprite.Create(Texture2D.whiteTexture, Rect.zero, Vector2.one); + /// + /// Appended string to file names to force a cache recreation, if changed + /// + private static string cacheRevision = "c0"; + /// /// Singleton instance /// @@ -217,7 +222,7 @@ private void CacheIcon(GameObject target, BepInPlugin plugin, Sprite rendered) private string GetCachePath(string name, string version) { - return Path.Combine(Utils.Paths.IconCachePath, $"{name}-{version}.png"); + return Path.Combine(Utils.Paths.IconCachePath, $"{name}-{version}-{cacheRevision}.png"); } private string GetVersion(BepInPlugin plugin)