Exemple #1
0
    public void InitSpriteAnimations()
    {
        if (selectedItemIndex == -1)
        {
            return;
        }

        ItemsCollection.ItemData itemData = itemsCollection.list[selectedItemIndex];

        this.spriteAnimationList = new List <SpriteAnimationItem>();
        foreach (int spriteId in itemData.GetSprites((Common.State)state))
        {
            SpriteCollection.SpriteData sprite = spriteCollection.GetSprite(spriteId);

            SpriteAnimationItem spriteAnimationData = new SpriteAnimationItem();
            spriteAnimationData.sprite          = sprite;
            spriteAnimationData.lastUpdatedTime = Time.realtimeSinceStartup;

            SpriteCollection.TextureData textureData = GetTextureDataDirection(sprite);

            spriteAnimationData.numberOfColumns = textureData.numberOfColumns;
            spriteAnimationData.numberOfRows    = textureData.numberOfRows;

            this.spriteAnimationList.Add(spriteAnimationData);
        }
        this.spriteAnimationList.Sort(SortByDepth);
    }
Exemple #2
0
    void RenderSpritesList()
    {
        ItemsCollection.ItemData itemData = itemsCollection.list[selectedItemIndex];

        foreach (int spriteId in itemData.GetSprites((Common.State)state))
        {
            SpriteCollection.SpriteData sprite = spriteCollection.GetSprite(spriteId);

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);

            //BOX
            Rect pos = GUILayoutUtility.GetLastRect();
            pos.height = 25;
            pos.x     += 20;
            pos.width  = WidthOfRightPanel - 25;
            GUI.Box(pos, "", "box");

            GUILayout.Label(sprite.name);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("-"))
            {
                removedSprites.Add(sprite);
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5);
        }

        foreach (SpriteCollection.SpriteData sprite in removedSprites)
        {
            itemData.RemoveSprite(sprite, (Common.State)state);
            this.InitSpriteAnimations();
        }

        if (removedSprites.Count != null)
        {
            removedSprites = new List <SpriteCollection.SpriteData>();
        }
    }