public override void OnInspectorGUI()
        {
            serializedObject.Update();

            if (spriteResolver.spriteLibChanged)
            {
                UpdateSpriteLibrary();
            }

            var currentlabelHashValue    = SpriteResolver.ConvertFloatToInt(m_SpritelabelHash.floatValue);
            var currentCategoryHashValue = SpriteResolver.ConvertFloatToInt(m_SpriteCategoryHash.floatValue);

            m_CategorySelectionIndex = Array.FindIndex(m_CategorySelectionHash, x => x == currentCategoryHashValue);
            ValidateCategorySelectionIndexValue();

            if (m_CategorySelection.Length == 1)
            {
                EditorGUILayout.LabelField(Style.noSpriteLibContainer);
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                m_CategorySelectionIndex = EditorGUILayout.Popup(Style.categoryLabel, m_CategorySelectionIndex, m_CategorySelection);
                if (m_CategorySelectionIndex != 0)
                {
                    var selection = m_SpriteLibSelection[m_CategorySelectionHash[m_CategorySelectionIndex]];
                    if (selection.names.Length <= 0)
                    {
                        EditorGUILayout.LabelField(Style.categoryIsEmptyLabel);
                    }
                    else
                    {
                        if (m_labelSelectionIndex < 0 || m_labelSelectionIndex >= selection.names.Length)
                        {
                            m_labelSelectionIndex = 0;
                        }
                        m_labelSelectionIndex = EditorGUILayout.Popup(Style.labelLabel, m_labelSelectionIndex, selection.names);
                        m_labelSelectionIndex = m_SpriteSelectorWidget.ShowGUI(m_labelSelectionIndex);
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    currentCategoryHashValue = m_CategorySelectionHash[m_CategorySelectionIndex];
                    if (m_SpriteLibSelection.ContainsKey(currentCategoryHashValue))
                    {
                        var hash = m_SpriteLibSelection[currentCategoryHashValue].nameHash;
                        if (hash.Length > 0)
                        {
                            if (m_labelSelectionIndex < 0 || m_labelSelectionIndex >= hash.Length)
                            {
                                m_labelSelectionIndex = 0;
                            }
                            currentlabelHashValue = m_SpriteLibSelection[currentCategoryHashValue].nameHash[m_labelSelectionIndex];
                        }
                    }

                    m_SpriteCategoryHash.floatValue = SpriteResolver.ConvertIntToFloat(currentCategoryHashValue);
                    m_SpritelabelHash.floatValue    = SpriteResolver.ConvertIntToFloat(currentlabelHashValue);
                    serializedObject.ApplyModifiedProperties();

                    var sf = target as SpriteResolver;
                    if (m_SpriteSkin != null)
                    {
                        m_SpriteSkin.ignoreNextSpriteChange = true;
                    }
                    sf.ResolveSpriteToSpriteRenderer();
                }

                if (m_PreviousCategoryHash != currentCategoryHashValue)
                {
                    if (m_SpriteLibSelection.ContainsKey(currentCategoryHashValue))
                    {
                        m_SpriteSelectorWidget.UpdateContents(m_SpriteLibSelection[currentCategoryHashValue].sprites);
                    }
                    m_PreviousCategoryHash = currentCategoryHashValue;
                }

                if (m_PreviouslabelHash != currentlabelHashValue)
                {
                    if (m_SpriteLibSelection.ContainsKey(currentCategoryHashValue))
                    {
                        m_labelSelectionIndex = Array.FindIndex(m_SpriteLibSelection[currentCategoryHashValue].nameHash, x => x == currentlabelHashValue);
                    }
                    m_PreviouslabelHash = currentlabelHashValue;
                }

                serializedObject.ApplyModifiedProperties();
                if (m_SpriteSelectorWidget.NeedUpdatePreview())
                {
                    this.Repaint();
                }
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            if (m_ReInitOnNextGUI)
            {
                m_ReInitOnNextGUI = false;
                UpdateSpriteLibrary();
            }

            if (spriteResolver.spriteLibChanged)
            {
                UpdateSpriteLibrary();
            }

            GetCategoryAndLabelStringValue(out var currentCategoryValue, out var currentLabelValue);
            var catIndex = Array.FindIndex(m_CategorySelection, x => x == currentCategoryValue);

            if (catIndex >= 0)
            {
                m_CategorySelectionIndex = catIndex;
            }
            ValidateCategorySelectionIndexValue();

            EditorGUI.BeginChangeCheck();
            using (new EditorGUI.DisabledScope(m_CategorySelection.Length <= 1))
                m_CategorySelectionIndex = EditorGUILayout.Popup(Style.categoryLabel, m_CategorySelectionIndex, m_CategorySelection);

            SpriteCategorySelectionList selection;

            m_SpriteLibSelection.TryGetValue(m_CategorySelection[m_CategorySelectionIndex], out selection);

            var entryNames = Style.emptyCategoryDropDownOption;

            if (selection.entryNames != null)
            {
                entryNames = selection.entryNames;
            }
            if (m_LabelSelectionIndex < 0 || m_LabelSelectionIndex >= entryNames.Length)
            {
                m_LabelSelectionIndex = 0;
            }
            using (new EditorGUI.DisabledScope(m_CategorySelectionIndex == 0 || entryNames.Length == 0))
            {
                if (entryNames.Length == 0)
                {
                    m_LabelSelectionIndex = EditorGUILayout.Popup(Style.labelLabel, 0, new [] { Style.categoryIsEmptyLabel });
                }
                else
                {
                    m_LabelSelectionIndex = EditorGUILayout.Popup(Style.labelLabel, m_LabelSelectionIndex, entryNames);
                }
            }

            m_LabelSelectionIndex = m_SpriteSelectorWidget.ShowGUI(m_LabelSelectionIndex);


            if (EditorGUI.EndChangeCheck())
            {
                currentCategoryValue = m_CategorySelection[m_CategorySelectionIndex];
                if (m_SpriteLibSelection.ContainsKey(currentCategoryValue))
                {
                    var hash = m_SpriteLibSelection[currentCategoryValue].entryNames;
                    if (hash.Length > 0)
                    {
                        if (m_LabelSelectionIndex < 0 || m_LabelSelectionIndex >= hash.Length)
                        {
                            m_LabelSelectionIndex = 0;
                        }
                        currentLabelValue = m_SpriteLibSelection[currentCategoryValue].entryNames[m_LabelSelectionIndex];
                    }
                }

                m_SpriteKey.floatValue = SpriteResolver.ConvertIntToFloat(SpriteLibrary.GetHashForCategoryAndEntry(currentCategoryValue, currentLabelValue));
                ApplyModifiedProperty();

                var sf = target as SpriteResolver;
                if (m_SpriteSkin != null)
                {
                    m_SpriteSkin.ignoreNextSpriteChange = true;
                }
                sf.ResolveSpriteToSpriteRenderer();
            }

            if (m_PreviousCategoryValue != currentCategoryValue)
            {
                if (!string.IsNullOrEmpty(currentCategoryValue))
                {
                    if (m_SpriteLibSelection.ContainsKey(currentCategoryValue))
                    {
                        m_SpriteSelectorWidget.UpdateContents(m_SpriteLibSelection[currentCategoryValue].sprites);
                    }
                    else
                    {
                        m_SpriteSelectorWidget.UpdateContents(new Sprite[0]);
                    }

                    this.Repaint();
                }

                m_PreviousCategoryValue = currentCategoryValue;
            }

            if (!string.IsNullOrEmpty(currentLabelValue) && m_PreviousLabelValue != currentLabelValue)
            {
                if (m_SpriteLibSelection.ContainsKey(currentCategoryValue))
                {
                    m_LabelSelectionIndex = Array.FindIndex(m_SpriteLibSelection[currentCategoryValue].entryNames, x => x == currentLabelValue);
                }
                m_PreviousLabelValue = currentLabelValue;
            }

            ApplyModifiedProperty();
            if (m_SpriteSelectorWidget.NeedUpdatePreview())
            {
                this.Repaint();
            }
        }