File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Assets/_PackageRoot/Runtime Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 1+ using System . Collections . Concurrent ;
12using System . Collections . Generic ;
23using UnityEngine ;
34
45namespace Extensions . Unity . ImageLoader
56{
67 public static partial class ImageLoader
78 {
8- internal static Dictionary < string , Sprite > memorySpriteCache = new Dictionary < string , Sprite > ( ) ;
9+ internal static ConcurrentDictionary < string , Sprite > memorySpriteCache = new ConcurrentDictionary < string , Sprite > ( ) ;
910
1011#if UNITY_EDITOR
1112 [ UnityEditor . InitializeOnEnterPlayMode ]
@@ -60,11 +61,11 @@ public static Sprite LoadFromMemoryCache(string url)
6061 /// <param name="url">URL to the picture, web or local</param>
6162 public static void ClearMemoryCache ( string url )
6263 {
63- var cache = memorySpriteCache . GetValueOrDefault ( url ) ;
64- if ( cache ? . texture != null )
65- UnityEngine . Object . DestroyImmediate ( cache . texture ) ;
66-
67- memorySpriteCache . Remove ( url ) ;
64+ if ( memorySpriteCache . Remove ( url , out var cache ) )
65+ {
66+ if ( cache ? . texture != null )
67+ UnityEngine . Object . DestroyImmediate ( cache . texture ) ;
68+ }
6869 }
6970 /// <summary>
7071 /// Clear Memory cache for all urls
You can’t perform that action at this time.
0 commit comments