调整 SpriteCache 的读取资源方式
将原来 UGF 事件回调风格的调用改成使用 UniTask 的异步操作
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Event;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -36,7 +37,7 @@ namespace SepCore.UI
|
||||
|
||||
private Vector3 _targetPos;
|
||||
|
||||
public void RefreshUI(DisplayItemInfoContext context)
|
||||
public async UniTaskVoid RefreshUI(DisplayItemInfoContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
@@ -64,20 +65,15 @@ namespace SepCore.UI
|
||||
_recycleButton.gameObject.SetActive(_context.ItemType == ItemType.Weapon);
|
||||
}
|
||||
|
||||
if (_iconArea != null)
|
||||
if (_iconArea != null && !string.IsNullOrEmpty(_context.IconAssetName))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_context.IconAssetName))
|
||||
string iconAssetName = _context.IconAssetName;
|
||||
var sprite = await GameEntry.SpriteCache.GetSprite(iconAssetName);
|
||||
if (_context != null && _context.IconAssetName == iconAssetName)
|
||||
{
|
||||
string iconAssetName = _context.IconAssetName;
|
||||
GameEntry.SpriteCache.GetSprite(iconAssetName, sprite =>
|
||||
{
|
||||
if (_context != null && _context.IconAssetName == iconAssetName)
|
||||
{
|
||||
_iconArea.OnInit(sprite, context.Rarity);
|
||||
ResizeToFitContent();
|
||||
ApplyClampedTargetPos();
|
||||
}
|
||||
});
|
||||
_iconArea.OnInit(sprite, context.Rarity);
|
||||
ResizeToFitContent();
|
||||
ApplyClampedTargetPos();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user