1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using UnityEngine;
- using FairyGUI;
- using YooAsset;
- namespace GFGGame
- {
- public class GFGGLoader : GLoader
- {
- private AssetOperationHandle handle;
- protected override void LoadExternal()
- {
- if (!YooAssets.CheckResExist(this.url))
- {
- return;
- }
- handle = YooAssets.LoadAssetAsync<Texture2D>(this.url);
- handle.Completed += Handle_Completed;
- }
- protected override void FreeExternal(NTexture texture)
- {
- //释放外部载入的资源
- if(handle != null)
- {
- handle.Release();
- }
- }
- 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();
- }
- }
- }
- }
|