int GetCategoryIndexForSprite(SpriteCategory category, TreeViewItem treeViewItem)
        {
            var spriteTreeViewItem = treeViewItem as TreeViewItemBase <ISpriteVisibilityItem>;
            var customData         = spriteTreeViewItem.customData as SpriteVisibilitySpriteItem;
            var characterPart      = customData != null ? customData.sprite : null;
            var index = -1;

            if (characterPart != null)
            {
                index = category.labels.FindIndex(x => x.spriteId == characterPart.sprite.id);
            }
            return(index);
        }
 public void CopyFrom(SpriteCategoryList categoryList)
 {
     categories.Clear();
     foreach (var cat in categoryList.categories)
     {
         var spriteLibCategory = new SpriteCategory()
         {
             name   = cat.name,
             labels = new List <SpriteCategoryLabel>(cat.labels)
         };
         categories.Add(spriteLibCategory);
     }
 }
        public SpriteCategoryList ToSpriteLibrary()
        {
            var spriteLibrary = new SpriteCategoryList();

            spriteLibrary.categories = new List <SpriteCategory>();
            foreach (var cat in categories)
            {
                var spriteLibCategory = new SpriteCategory()
                {
                    name   = cat.name,
                    labels = new List <SpriteCategoryLabel>(cat.labels)
                };
                spriteLibrary.categories.Add(spriteLibCategory);
            }
            return(spriteLibrary);
        }
        public string GetSpriteLabelName(SpriteCategory category, TreeViewItem treeViewItem)
        {
            var spriteTreeViewItem = treeViewItem as TreeViewItemBase <ISpriteVisibilityItem>;
            var customData         = spriteTreeViewItem.customData as SpriteVisibilitySpriteItem;
            var characterPart      = customData != null ? customData.sprite : null;
            var index = -1;

            if (characterPart != null)
            {
                index = category.labels.FindIndex(x => x.spriteId == characterPart.sprite.id);
            }
            if (index >= 0)
            {
                return(category.labels[index].name);
            }
            return("");
        }
        public bool IsLabelDuplicate(SpriteCategory category, string labelName)
        {
            var hash = SpriteLibraryAsset.GetStringHash(labelName);

            return(category.labels.Count(x => x.name == labelName || hash == SpriteLibraryAsset.GetStringHash(x.name)) > 1);
        }