You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
1.2 KiB

using System.Collections.Generic;
using System.Threading;
using FairyGUI;
using UnityEngine;
using UnityEngine.U2D;
namespace ET
{
public class FUIGLoader : GLoader
{
private Dictionary<NTexture, Sprite> Texture_Sprite_Dict = new();
protected override void LoadExternal()
{
// 加载图集中的图片规则为:图集名[图片名]
// 例如:BuildingAtlas[Build_1001]
var url = this.url;
Sprite sprite = YooAssetComponent.Instance.LoadAssetSync<Sprite>(url);
if (sprite == null)
{
Log.Error("can't load sprite " + url);
this.onExternalLoadFailed();
return;
}
var tex = new NTexture(sprite);
this.Texture_Sprite_Dict.Add(tex, sprite);
this.onExternalLoadSuccess(tex);
}
protected override void FreeExternal(NTexture texture)
{
if (this.Texture_Sprite_Dict.TryGetValue(texture, out Sprite sprite))
{
YooAssetComponent.Instance.Release(sprite);
this.Texture_Sprite_Dict.Remove(texture);
}
}
}
}