private void DrawPicker()
        {
            if (m_VectorImageDatas[0] == null)
            {
                GUILayout.Label("Invalid vector image");
                return;
            }

            if (m_VectorImageDatas[0].glyph == null)
            {
                GUILayout.Label("Invalid glyph");
                return;
            }

            if (m_VectorImageDatas[0].font == null)
            {
                m_VectorImageDatas[0].font = VectorImageManager.GetIconFont(VectorImageManager.GetAllIconSetNames()[1]);
            }

            var names = VectorImageManager.GetAllIconSetNames();

            if (!names.Contains(m_VectorImageDatas[0].font.name))
            {
                m_VectorImageDatas[0].font.name = names[1];
            }

            if (VectorImageManager.GetAllIconSetNames().Length > 0)
            {
                EditorGUI.BeginChangeCheck();
                var namesContents = new GUIContent[names.Length];
                for (var i = 0; i < names.Length; i++)
                {
                    namesContents[i] = new GUIContent(names[i]);
                }

                m_VectorImageDatas[0].font = VectorImageManager.GetIconFont(names[
                                                                                EditorGUILayout.Popup(new GUIContent("Current Pack"),
                                                                                                      names.ToList().IndexOf(m_VectorImageDatas[0].font.name), namesContents)]);

                var changed = EditorGUI.EndChangeCheck();

                if (changed)
                {
                    m_IconViewScrollPosition = Vector2.zero;
                }

                if (changed || m_VectorImageSet == null || m_IconFont == null)
                {
                    UpdateFontPackInfo();
                }

                DrawIconList();
            }
            else
            {
                EditorGUILayout.HelpBox("No VectorImage fonts detected!", MessageType.Warning);
            }

            DrawBottomBar();
        }
Beispiel #2
0
        public static void DrawIconPickLine(VectorImageData data, Object objectToRefresh, bool indent = false)
        {
            using (new GUILayout.HorizontalScope())
            {
                if (data.font == null)
                {
                    data.font = VectorImageManager.GetIconFont(VectorImageManager.GetAllIconSetNames()[0]);
                }

                GUIStyle iconGuiStyle = new GUIStyle {
                    font = VectorImageManager.GetIconFont(data.font.name)
                };

                EditorGUILayout.PrefixLabel("Icon");

                if (indent)
                {
                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.LabelField(IconDecoder.Decode(data.glyph.unicode), iconGuiStyle, GUILayout.Width(18f));
                EditorGUILayout.LabelField(data.glyph.name, GUILayout.MaxWidth(100f), GUILayout.MinWidth(0f));

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Pick icon", EditorStyles.miniButton, GUILayout.MaxWidth(60f)))
                {
                    Show(data, objectToRefresh);
                    return;
                }

                if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.MaxWidth(20f)))
                {
                    for (int i = 0; i < m_VectorImageDatas.Length; i++)
                    {
                        m_VectorImageDatas[i] = null;
                    }
                    return;
                }

                if (indent)
                {
                    EditorGUI.indentLevel++;
                }
            }
        }
Beispiel #3
0
        protected void CacheIconSets()
        {
            var names = new System.Collections.Generic.List <string>(VectorImageManager.GetAllIconSetNames());

            var supportTmp   = SupportTMProFont();
            var supportUnity = SupportUnityFont();

            if (!supportTmp || !supportUnity)
            {
                for (int i = 0; i < names.Count; i++)
                {
                    var v_font = VectorImageManager.GetIconFont(names[i]);
                    if (v_font == null || (v_font.SupportTMProFont() != supportTmp && v_font.SupportUnityFont() != supportUnity))
                    {
                        names.RemoveAt(i);
                        i--;
                    }
                }
            }
            validIconSetNames = names.ToArray();
        }