图片模糊功能bug修改

This commit is contained in:
CaiYanPeng 2021-12-29 17:17:15 +08:00
parent 95d845ac0f
commit 0e16fec75a
2 changed files with 16 additions and 0 deletions

View File

@ -13,6 +13,7 @@ public class NewRouteDetailController : PFUIPanel
{ {
// Start is called before the first frame update // Start is called before the first frame update
Dictionary<string, Texture> caches; Dictionary<string, Texture> caches;
Dictionary<string, byte[]> cacheByte;
GameObject map; GameObject map;
ScrollRect scroll; ScrollRect scroll;
Dictionary<bool, Sprite> FavDict; Dictionary<bool, Sprite> FavDict;
@ -26,6 +27,7 @@ public class NewRouteDetailController : PFUIPanel
{true,Resources.Load<Sprite>("Images/NewDesign/icon_heji_like") }, {true,Resources.Load<Sprite>("Images/NewDesign/icon_heji_like") },
}; };
caches = new Dictionary<string, Texture>(); caches = new Dictionary<string, Texture>();
cacheByte = new Dictionary<string, byte[]>();
scroll = transform.Find("Container/Right/Scroll View").GetComponent<ScrollRect>(); scroll = transform.Find("Container/Right/Scroll View").GetComponent<ScrollRect>();
UIManager.AddEvent(scroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag); UIManager.AddEvent(scroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
#if UNITY_ANDROID || UNITY_IOS #if UNITY_ANDROID || UNITY_IOS
@ -38,6 +40,7 @@ public class NewRouteDetailController : PFUIPanel
protected override void OnDestroy() protected override void OnDestroy()
{ {
caches = null; caches = null;
cacheByte = null;
Resources.UnloadUnusedAssets(); Resources.UnloadUnusedAssets();
GC.Collect(); GC.Collect();
Debug.Log("list empty"); Debug.Log("list empty");
@ -150,6 +153,15 @@ public class NewRouteDetailController : PFUIPanel
Utils.DisplayImageTempDict(left.Find("Icon").GetComponent<RawImage>(), area.CoverImage, caches Utils.DisplayImageTempDict(left.Find("Icon").GetComponent<RawImage>(), area.CoverImage, caches
, b => , b =>
{ {
if (b != null)
{
cacheByte.Add(area.CoverImage, b);
}
else if(cacheByte.ContainsKey(area.CoverImage))
{
b = cacheByte[area.CoverImage];
}
#if UNITY_EDITOR #if UNITY_EDITOR
var _t = new Texture2D(4, 4, TextureFormat.DXT5, false); var _t = new Texture2D(4, 4, TextureFormat.DXT5, false);
#else #else

View File

@ -404,6 +404,10 @@ namespace Assets.Scripts
{ {
img.GetComponent<Image>().ShowImageWithTexture(texture); img.GetComponent<Image>().ShowImageWithTexture(texture);
} }
if (callback != null)
{
callback.Invoke(null);
}
return; return;
} }
} }