🐛 Fixed exporter not bailing out when failing to parse fst

This commit is contained in:
Edgar 2023-08-24 12:54:29 +02:00
parent 1e3457cfd4
commit 9fe14a4396
No known key found for this signature in database
GPG key ID: 9AA5DDFFCBDCE46A

View file

@ -1,4 +1,4 @@
// AvatarExporter.cs // AvatarExporter.cs
// //
// Created by David Back on 28 Nov 2018 // Created by David Back on 28 Nov 2018
// Copyright 2018 High Fidelity, Inc. // Copyright 2018 High Fidelity, Inc.
@ -418,33 +418,25 @@ class AvatarExporter : MonoBehaviour
{ {
bool copyModelToExport = false; bool copyModelToExport = false;
// lookup the project name field from the fst file to update
projectName = "";
try try
{ {
string[] lines = File.ReadAllLines(exportFstPath); currentFst = new FST();
foreach (string line in lines) // load the old file first
if(!currentFst.LoadFile(exportFstPath))
{ {
int separatorIndex = line.IndexOf("="); EditorUtility.DisplayDialog("Error",
if (separatorIndex >= 0) $"Failed to read from existing file {exportFstPath}. Please check the file and try again.", "Ok");
{ return;
string key = line.Substring(0, separatorIndex).Trim();
if (key == "name")
{
projectName = line.Substring(separatorIndex + 1).Trim();
break;
}
}
} }
} }
catch catch
{ {
EditorUtility.DisplayDialog("Error", "Failed to read from existing file " + exportFstPath + EditorUtility.DisplayDialog("Error",
". Please check the file and try again.", "Ok"); $"Failed to read from existing file {exportFstPath}. Please check the file and try again.", "Ok");
return; return;
} }
string exportModelPath = Path.GetDirectoryName(exportFstPath) + "/" + assetName + ".fbx"; string exportModelPath = $"{Path.GetDirectoryName(exportFstPath)}/{assetName}.fbx";
if (File.Exists(exportModelPath)) if (File.Exists(exportModelPath))
{ {
// if the fbx in Unity Assets is newer than the fbx in the target export // if the fbx in Unity Assets is newer than the fbx in the target export
@ -529,9 +521,6 @@ class AvatarExporter : MonoBehaviour
} }
} }
currentFst = new FST();
// load the old file first
currentFst.LoadFile(exportFstPath);
currentFst.scale = scale; currentFst.scale = scale;
// write out a new fst file in place of the old file // write out a new fst file in place of the old file