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; } } } }
public void DrawInspector() { VectorImageManagerWindow.DrawHeader("Import custom icon fonts"); { VectorImageManagerWindow.BeginContents(); { EditorGUILayout.HelpBox("To create a custom font with your own svg files, you just need to go on one of these websites, follow the steps, download the zip file and finaly import it using the 'Import' button below.", MessageType.Info); for (int i = 0; i < vectorImageFontParserArray.Length; i++) { VectorImageFontParser vectorImageFontParser = vectorImageFontParserArray[i]; using (new GUILayout.VerticalScope()) { using (new GUILayout.HorizontalScope()) { EditorGUILayout.LabelField(m_IconFontParserNameArray[i], EditorStyles.boldLabel, GUILayout.Width(110f)); GUILayout.FlexibleSpace(); if (GUILayout.Button("Website", EditorStyles.miniButtonLeft, GUILayout.Width(60f))) { Application.OpenURL(vectorImageFontParser.GetWebsite()); } if (GUILayout.Button("Import", EditorStyles.miniButtonRight, GUILayout.Width(60f))) { vectorImageFontParser.DownloadIcons(() => { Debug.Log("Your custom font has been imported to " + vectorImageFontParser.GetFolderPath()); }); } GUILayout.Space(2f); } } } } VectorImageManagerWindow.EndContents(); } }