Exemplo n.º 1
0
        private void DrawWebFontLine(VectorImageFontParser vectorImageFontParser, bool showDeleteButton = true)
        {
            using (new GUILayout.VerticalScope())
            {
                using (new GUILayout.HorizontalScope())
                {
                    var displayedFontName = vectorImageFontParser.GetFontName();
                    if (displayedFontName.Length > 15)
                    {
                        displayedFontName = displayedFontName.Substring(0, 15);
                    }
                    EditorGUILayout.LabelField(displayedFontName, EditorStyles.boldLabel, GUILayout.Width(110f));

                    var iconCountInfo = string.Empty;
                    if (vectorImageFontParser.IsFontAvailable())
                    {
                        iconCountInfo = vectorImageFontParser.GetCachedIconSet().iconGlyphList.Count + " icons";
                    }
                    EditorGUILayout.LabelField(iconCountInfo, GUILayout.Width(60f));

                    GUILayout.FlexibleSpace();

                    if (GUILayout.Button("Website", EditorStyles.miniButtonLeft, GUILayout.Width(60f)))
                    {
                        Application.OpenURL(vectorImageFontParser.GetWebsite());
                    }

                    var downloadInfo = vectorImageFontParser.IsFontAvailable() ? "Update" : "Download";
                    if (GUILayout.Button(downloadInfo,
                                         showDeleteButton ? EditorStyles.miniButtonMid : EditorStyles.miniButtonRight,
                                         GUILayout.Width(60f)))
                    {
                        EditorUtility.DisplayProgressBar("Downloading font icon",
                                                         "Downloading " + vectorImageFontParser.GetFontName() + "...", 0.0f);

                        vectorImageFontParser.DownloadIcons(() => { EditorUtility.ClearProgressBar(); });
                    }

                    if (showDeleteButton)
                    {
                        GUI.enabled = vectorImageFontParser.IsFontAvailable();
                        if (GUILayout.Button("Delete", EditorStyles.miniButtonRight, GUILayout.Width(60f)))
                        {
                            if (EditorUtility.DisplayDialog("Delete " + vectorImageFontParser.GetFontName(),
                                                            "Are you sure you want to delete this font icon?", "Delete", "Cancel"))
                            {
                                vectorImageFontParser.Delete();
                            }
                        }
                        GUI.enabled = true;
                    }
                }
            }
        }