protected void _LoadSpriteABAsyn(XUITextureConfig.TextureInfo textureInfo, Action <Sprite> OnComplete)
 {
     if (string.IsNullOrEmpty(textureInfo.atlasName))
     {
         m_AssetLoader.LoadAssetAsyn <Sprite>(textureInfo.path, sprite =>
         {
             if (sprite == null)
             {
                 Debug.LogError($"没有找到sprite {textureInfo.ToLog()}");
             }
             OnComplete?.Invoke(sprite);
         });
     }
     else
     {
         m_AssetLoader.LoadAssetAsyn <SpriteAtlas>(textureInfo.path, spriteAtlas =>
         {
             //Debug.Log($"LoadAsset SpriteAtlas {textureInfo.path} {spriteAtlas}");
             var sprite = spriteAtlas.GetSprite(textureInfo.name);
             if (sprite == null)
             {
                 Debug.LogError($"没有找到sprite {textureInfo.ToLog()}");
             }
             OnComplete?.Invoke(sprite);
         });
     }
 }
 public Sprite LoadSprite(XUITextureConfig.TextureInfo textureInfo)
 {
     if (textureInfo.buildin)
     {
         return(_LoadSpriteBI(textureInfo));
     }
     return(_LoadSpriteAB(textureInfo));
 }
 public void LoadSpriteAsyn(XUITextureConfig.TextureInfo textureInfo, Action <Sprite> OnComplete = null)
 {
     if (textureInfo.buildin)
     {
         OnComplete?.Invoke(_LoadSpriteBI(textureInfo));
     }
     else
     {
         _LoadSpriteABAsyn(textureInfo, OnComplete);
     }
 }
        public void AddData(string name, XUITextureConfig.TextureInfo info)
        {
            name = name.ToLower();
            var dict = _GetOrCreateDatas(info.language);

            if (dict.ContainsKey(name))
            {
                Debug.LogError($"已经存在 {name}");
                return;
            }
            dict.Add(name, info);
        }
        protected Sprite _LoadSpriteBI(XUITextureConfig.TextureInfo textureInfo)
        {
            Sprite sprite = null;

            if (string.IsNullOrEmpty(textureInfo.atlasName))
            {
                sprite = Resources.Load <Sprite>(textureInfo.path);
            }
            else
            {
                var atlas = Resources.Load <SpriteAtlas>(textureInfo.path);
                if (atlas != null)
                {
                    sprite = atlas.GetSprite(textureInfo.name);
                }
            }
            if (sprite == null)
            {
                Debug.LogError($"没有找到sprite {textureInfo.ToLog()}");
                return(null);
            }
            return(sprite);
        }
        protected Sprite _LoadSpriteAB(XUITextureConfig.TextureInfo textureInfo)
        {
            Sprite sprite = null;

            if (string.IsNullOrEmpty(textureInfo.atlasName))
            {
                sprite = m_AssetLoader.LoadAsset <Sprite>(textureInfo.path);
            }
            else
            {
                var atlas = m_AssetLoader.LoadAsset <SpriteAtlas>(textureInfo.path);
                Debug.Log($"LoadAsset SpriteAtlas {textureInfo.path} {atlas}");
                if (atlas != null)
                {
                    sprite = atlas.GetSprite(textureInfo.name);
                }
            }
            if (sprite == null)
            {
                Debug.LogError($"没有找到sprite {textureInfo.ToLog()}");
                return(null);
            }
            return(sprite);
        }