| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | using UnityEngine;using FairyGUI;using YooAsset;namespace GFGGame{    public class GFGGLoader : GLoader    {        private AssetOperationHandle handle;        protected override void LoadExternal()        {            //LogUtil.LogEditor($"GFGGLoader this.url {this.url}");            if (!YooAssets.CheckResExist(this.url))            {                return;            }            bool isAsync = !this.url.Contains(ResPathUtil.TEXTURE_BGIMG_DIR_PATH);            if (isAsync)            {                //异步                handle = YooAssets.LoadAssetAsync<Texture2D>(this.url);                handle.Completed += Handle_Completed;            }            else            {                //同步                handle = YooAssets.LoadAssetSync<Texture2D>(this.url);                Handle_Completed(handle);            }        }        protected override void FreeExternal(NTexture texture)        {            //释放外部载入的资源            if(handle != null)            {                handle.Release();                handle = null;            }        }        void Handle_Completed(AssetOperationHandle handle)        {            if(handle.GetAssetInfo().AssetPath != this.url)            {                handle.Release();                return;            }            Texture2D texture = handle.AssetObject as Texture2D;            if (texture != null)            {                onExternalLoadSuccess(new NTexture(texture));            }            else            {                onExternalLoadFailed();            }        }    }}
 |