コード例 #1
0
        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);
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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("");
        }
コード例 #5
0
        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);
        }