UnityEditor.TrueTypeFontImporterInspector.GetUniquePath C# (CSharp) Method

GetUniquePath() private static method

private static GetUniquePath ( string basePath, string extension ) : string
basePath string
extension string
return string
        private static string GetUniquePath(string basePath, string extension)
        {
            for (int i = 0; i < 0x2710; i++)
            {
                string path = basePath + ((i != 0) ? (string.Empty + i) : string.Empty) + "." + extension;
                if (!File.Exists(path))
                {
                    return path;
                }
            }
            return string.Empty;
        }

Usage Example

        private static void CreateEditableCopy(MenuCommand command)
        {
            TrueTypeFontImporter trueTypeFontImporter = command.context as TrueTypeFontImporter;

            if (trueTypeFontImporter.fontTextureCase == FontTextureCase.Dynamic)
            {
                EditorUtility.DisplayDialog("Cannot generate editabled font asset for dynamic fonts", "Please reimport the font in a different mode.", "Ok");
                return;
            }
            string str = Path.GetDirectoryName(trueTypeFontImporter.assetPath) + "/" + Path.GetFileNameWithoutExtension(trueTypeFontImporter.assetPath);

            EditorGUIUtility.PingObject(trueTypeFontImporter.GenerateEditableFont(TrueTypeFontImporterInspector.GetUniquePath(str + "_copy", "fontsettings")));
        }