예제 #1
0
 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);
         });
     }
 }
예제 #2
0
 public Sprite LoadSprite(XUITextureConfig.TextureInfo textureInfo)
 {
     if (textureInfo.buildin)
     {
         return(_LoadSpriteBI(textureInfo));
     }
     return(_LoadSpriteAB(textureInfo));
 }
예제 #3
0
 public void LoadSpriteAsyn(XUITextureConfig.TextureInfo textureInfo, Action <Sprite> OnComplete = null)
 {
     if (textureInfo.buildin)
     {
         OnComplete?.Invoke(_LoadSpriteBI(textureInfo));
     }
     else
     {
         _LoadSpriteABAsyn(textureInfo, OnComplete);
     }
 }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }