Skip to content

Commit b677614

Browse files
committed
always use valid filename when exporting
replace any invalid characters with an underscore
1 parent b083fa5 commit b677614

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ private static List<GameObject> OnConvertInPlace (GameObject [] unityActiveGOs)
7676
string dirPath = Path.Combine (Application.dataPath, "Objects");
7777

7878
for(int n = 0; n < gosToExport.Length; n++){
79-
filePaths[n] = Path.Combine (dirPath, gosToExport[n].name + ".fbx");
79+
string filename = ConvertToValidFilename (gosToExport [n].name + ".fbx");
80+
filePaths[n] = Path.Combine (dirPath, filename);
8081
}
8182

8283
string[] fbxFileNames = new string[filePaths.Length];
@@ -136,6 +137,11 @@ private static List<GameObject> OnConvertInPlace (GameObject [] unityActiveGOs)
136137
return result;
137138
}
138139

140+
private static string ConvertToValidFilename(string filename)
141+
{
142+
return System.Text.RegularExpressions.Regex.Replace (filename, "[" + new string(Path.GetInvalidFileNameChars()) + "]", "_");
143+
}
144+
139145
private static void SetupImportedGameObject(GameObject orig, GameObject imported)
140146
{
141147
Transform importedTransform = imported.transform;

0 commit comments

Comments
 (0)