internal Sprite GetSprite(int categoryHash, int labelHash, out bool validEntry)
        {
            SpriteLibCategory category = null;

            for (int i = 0; i < m_Labels.Count; ++i)
            {
                if (m_Labels[i].hash == categoryHash)
                {
                    category = m_Labels[i];
                    break;
                }
            }

            if (category != null)
            {
                SpriteCategoryEntry spritelabel = null;
                for (int i = 0; i < category.categoryList.Count; ++i)
                {
                    if (category.categoryList[i].hash == labelHash)
                    {
                        spritelabel = category.categoryList[i];
                        break;
                    }
                }
                if (spritelabel != null)
                {
                    validEntry = true;
                    return(spritelabel.sprite);
                }
            }
            validEntry = false;
            return(null);
        }
        /// <summary>
        /// Remove a Label from a given Category
        /// </summary>
        /// <param name="category">Category to remove from</param>
        /// <param name="label">Label to remove</param>
        /// <param name="deleteCategory">Indicate to remove the Category if it is empty</param>
        public void RemoveCategoryLabel(string category, string label, bool deleteCategory)
        {
            var catHash = SpriteLibraryAsset.GetStringHash(category);
            SpriteLibCategory libCategory = null;

            libCategory = m_Labels.FirstOrDefault(x => x.hash == catHash);

            if (libCategory != null)
            {
                var labelHash = SpriteLibraryAsset.GetStringHash(label);
                libCategory.categoryList.RemoveAll(x => x.hash == labelHash);
                if (deleteCategory && libCategory.categoryList.Count == 0)
                {
                    m_Labels.RemoveAll(x => x.hash == libCategory.hash);
                }
#if UNITY_EDITOR
                EditorUtility.SetDirty(this);
#endif
            }
        }
        /// <summary>
        /// Add or replace and existing Sprite into the given Category and Label
        /// </summary>
        /// <param name="sprite">Sprite to add</param>
        /// <param name="category">Category to add the Sprite to</param>
        /// <param name="label">Label of the Category to add the Sprite to. If this parameter is null or an empty string, it will attempt to add a empty category</param>
        public void AddCategoryLabel(Sprite sprite, string category, string label)
        {
            category = category.Trim();
            label    = label?.Trim();
            if (string.IsNullOrEmpty(category))
            {
                throw new ArgumentException("Cannot add empty or null Category string");
            }

            var catHash = SpriteLibraryAsset.GetStringHash(category);
            SpriteCategoryEntry categorylabel = null;
            SpriteLibCategory   libCategory   = null;

            libCategory = m_Labels.FirstOrDefault(x => x.hash == catHash);

            if (libCategory != null)
            {
                if (string.IsNullOrEmpty(label))
                {
                    throw new ArgumentException("Cannot add empty or null Label string");
                }
                Assert.AreEqual(libCategory.name, category, "Category string  hash clashes with another existing Category. Please use another string");

                var labelHash = SpriteLibraryAsset.GetStringHash(label);
                categorylabel = libCategory.categoryList.FirstOrDefault(y => y.hash == labelHash);
                if (categorylabel != null)
                {
                    Assert.AreEqual(categorylabel.name, label, "Label string hash clashes with another existing label. Please use another string");
                    categorylabel.sprite = sprite;
                }
                else
                {
                    categorylabel = new SpriteCategoryEntry()
                    {
                        name   = label,
                        sprite = sprite
                    };
                    libCategory.categoryList.Add(categorylabel);
                }
            }
            else
            {
                var slc = new SpriteLibCategory()
                {
                    categoryList = new List <SpriteCategoryEntry>(),
                    name         = category
                };
                if (!string.IsNullOrEmpty(label))
                {
                    slc.categoryList.Add(new SpriteCategoryEntry()
                    {
                        name   = label,
                        sprite = sprite
                    });
                }
                m_Labels.Add(slc);
            }
#if UNITY_EDITOR
            EditorUtility.SetDirty(this);
#endif
        }