Skip to content

Commit c8456b3

Browse files
committed
fixed in ExportCache: for Textures only > added tex.updateCount to cache filename, to ensure we don't use an older version from cache
1 parent 295a5d9 commit c8456b3

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Runtime/Scripts/Cache/ExportCache.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,20 @@ public static string CacheDirectory
3434
}
3535
}
3636

37+
#if UNITY_EDITOR
38+
private static string GetPath(Object asset, string seed)
39+
{
40+
if (asset is Texture tex)
41+
seed += $"_{tex.updateCount}";
42+
43+
return CacheDirectory + "/" + GlobalObjectId.GetGlobalObjectIdSlow(asset) + seed;
44+
}
45+
#endif
46+
3747
public static bool TryGetBytes(Object asset, string seed, out byte[] bytes)
3848
{
3949
#if UNITY_EDITOR
40-
var path = CacheDirectory + "/" + GlobalObjectId.GetGlobalObjectIdSlow(asset) + seed;
50+
var path = GetPath(asset, seed);
4151
if (File.Exists(path))
4252
{
4353
bytes = File.ReadAllBytes(path);
@@ -54,7 +64,7 @@ public static void AddBytes(Object asset, string seed, byte[] bytes)
5464
#if UNITY_EDITOR
5565
var dir = CacheDirectory;
5666
Directory.CreateDirectory(dir);
57-
var path = dir + "/" + GlobalObjectId.GetGlobalObjectIdSlow(asset) + seed;
67+
var path = GetPath(asset, seed);
5868
// Debug.Log($"Writing {bytes.Length} bytes to cache: {path}");
5969
File.WriteAllBytes(path, bytes);
6070
#endif

0 commit comments

Comments
 (0)