Skip to content

Commit ad6b92f

Browse files
committed
fix: 修正异步资源加载成功状态检查条件
将 assetHandle.IsSucceed() 替换为更精确的 assetHandle.IsDone && assetHandle.Status == EOperationStatus.Succeed,避免在异步操作未完成时误判状态
1 parent 47d8987 commit ad6b92f

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

Runtime/UGUIImageExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static async void SetIcon(this UnityEngine.UI.Image self, string icon)
5151
var assetComponent = GameEntry.GetComponent<AssetComponent>();
5252
using (var valueHandle = await assetComponent.LoadAssetAsync<Texture2D>(icon))
5353
{
54-
if (valueHandle.IsSucceed())
54+
if (valueHandle.IsDone && valueHandle.Status == EOperationStatus.Succeed)
5555
{
5656
var texture2D = valueHandle.GetAssetObject<Texture2D>();
5757
self.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f));

Runtime/UIManager.Open.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private async Task<IUIForm> InnerLoadUIFormAsync(string uiFormAssetPath, Type ui
112112

113113
// 从包中加载
114114
var assetHandle = await m_AssetManager.LoadAssetAsync<UnityEngine.Object>(assetPath);
115-
if (assetHandle.IsSucceed())
115+
if (assetHandle.IsDone && assetHandle.Status == EOperationStatus.Succeed)
116116
{
117117
// 加载成功
118118
var gameObject = assetHandle.InstantiateSync();

0 commit comments

Comments
 (0)