using System.Collections.Generic; using System.Threading; using FairyGUI; using UnityEngine; using UnityEngine.U2D; namespace ET { public class FUIGLoader : GLoader { private Dictionary Texture_Sprite_Dict = new(); protected override void LoadExternal() { // 加载图集中的图片规则为:图集名[图片名] // 例如:BuildingAtlas[Build_1001] var url = this.url; Sprite sprite = YooAssetComponent.Instance.LoadAssetSync(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); } } } }