GLoader在被销毁时,没有调用FreeExternal
UIObjectFactory.SetLoaderExtension(typeof(FairyGLoader));
public class FairyGLoader : GLoader {
override protected async void LoadExternal()
{
try {
Texture texture = await AssetsManager.Instance.LoadAssetAsync<Texture>(url);
NTexture nTexture = new(texture);
this.OnLoadSuccess(nTexture);
} catch (Exception e) {
this.OnLoadFail(e.ToString());
throw e;
}
}
override protected void FreeExternal(NTexture nTexture)
{
AssetsManager.Instance.UnloadAsset(url);
}
private void OnLoadSuccess(NTexture texture)
{
if (texture == null) {
Debug.Log($"<color=#33FFFF>load UI Texture faile:texture is null</color>");
return;
}
if (texture.nativeTexture == null)
{
Debug.Log($"<color=#33FFFF>load UI Texture faile:texture.nativeTexture is null</color>");
return;
}
#if UNITY_EDITOR
Debug.Log($"<color=#33FFFF>load UI Texture :{this.url} suc:{texture.nativeTexture.name}</color>");
#endif
this.onExternalLoadSuccess(texture);
}
private void OnLoadFail(string error)
{
#if UNITY_EDITOR
Debug.Log($"color=#33FFFF>load UI Texture :{this.url } failed: {error}");
#endif
this.onExternalLoadFailed();
}
}
GLoader 切换Icon的时候,url设置可以正确调用LoadExternal,并且可以触发FreeExternal,但是关闭页面的时候,不会触发FreeExternal。请问如何解决。
没有找到相关结果
已邀请:
1 个回复
谷主
赞同来自: