Exemplo n.º 1
0
        private void LoadSprites(string animationName)
        {
            var sprites = new List <Sprite>();
            var count   = sourceAtlas.GetListOfSprites().Count(x => x.StartsWith(animationName));

            for (var i = 0; i < count; i++)
            {
                var spriteName = string.Format("{0}_{1}", animationName, i);

                Sprite sprite = null;

                sprite = spriteCache.GetValueOrDefault(spriteName);

                if (sprite != null)
                {
                    sprites.Add(sprite);
                    continue;
                }

                sprite = sourceAtlas.GetSprite(spriteName);

                if (sprite != null)
                {
                    spriteCache.Add(spriteName, sprite);
                    sprites.Add(sprite);
                }
                else
                {
                    break;
                }
            }

            animationSprites = sprites.ToArray();
        }
Exemplo n.º 2
0
        public void Apply()
        {
            if (targetImage == null)
            {
                targetImage = UnityUtility.GetComponent <Image>(gameObject);
            }

            if (targetImage != null && atlas != null)
            {
                var spriteData = atlas.GetSpriteData(spriteGuid);

                if (spriteData != null)
                {
                    spriteName = spriteData.name;
                }

                Sprite = string.IsNullOrEmpty(spriteName) ? null : atlas.GetSprite(spriteName);

                targetImage.sprite = Sprite;
            }
        }