private void ConvertLayerToCategory(ISpriteVisibilityItem treeViewItem)
 {
     if (SupportConvertToCatgory(treeViewItem))
     {
         var groupItem = treeViewItem as SpriteVisibilityGroupItem;
         foreach (var item in groupItem.childItems)
         {
             ConvertLayerToCategory(item);
         }
     }
     else
     {
         var groupItem = treeViewItem as SpriteVisibilitySpriteItem;
         var name      = groupItem.sprite.sprite.name;
         SetCategoryForSprite(name, name, groupItem);
     }
 }
        void SetCategoryForSprite(string categoryName, string labelName, ISpriteVisibilityItem spriteVisibilityItem)
        {
            categoryName = categoryName.Trim();
            labelName    = labelName.Trim();
            var customData    = spriteVisibilityItem as SpriteVisibilitySpriteItem;
            var characterPart = customData != null ? customData.sprite : null;

            if (characterPart != null && characterPart.sprite != null)
            {
                var spriteLib = m_Model.spriteCategoryList;
                using (m_Model.UndoScope(TextContent.spriteCategoryChanged))
                {
                    spriteLib.AddSpriteToCategory(categoryName, new SpriteCategoryLabel()
                    {
                        name     = labelName,
                        spriteId = characterPart.sprite.id
                    }
                                                  );
                    m_Events.spriteLibraryChanged.Invoke();
                }
            }
        }
 private bool SupportConvertToCatgory(ISpriteVisibilityItem treeViewItem)
 {
     return(treeViewItem is SpriteVisibilityGroupItem);
 }
 int SpriteVisibilityItemOrderSort(ISpriteVisibilityItem x, ISpriteVisibilityItem y)
 {
     return(x.characterOrder.order.CompareTo(y.characterOrder.order));
 }