From 9fe14a4396984bc992b22c45b93014eced056e99 Mon Sep 17 00:00:00 2001 From: Edgar Date: Thu, 24 Aug 2023 12:54:29 +0200 Subject: [PATCH] :bug: Fixed exporter not bailing out when failing to parse fst --- .../Editor/AvatarExporter/AvatarExporter.cs | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/tools/unity-avatar-exporter/Assets/Editor/AvatarExporter/AvatarExporter.cs b/tools/unity-avatar-exporter/Assets/Editor/AvatarExporter/AvatarExporter.cs index 2c83e38e04..a4b079d000 100644 --- a/tools/unity-avatar-exporter/Assets/Editor/AvatarExporter/AvatarExporter.cs +++ b/tools/unity-avatar-exporter/Assets/Editor/AvatarExporter/AvatarExporter.cs @@ -1,4 +1,4 @@ -// AvatarExporter.cs +// AvatarExporter.cs // // Created by David Back on 28 Nov 2018 // Copyright 2018 High Fidelity, Inc. @@ -418,33 +418,25 @@ class AvatarExporter : MonoBehaviour { bool copyModelToExport = false; - // lookup the project name field from the fst file to update - projectName = ""; try { - string[] lines = File.ReadAllLines(exportFstPath); - foreach (string line in lines) + currentFst = new FST(); + // load the old file first + if(!currentFst.LoadFile(exportFstPath)) { - int separatorIndex = line.IndexOf("="); - if (separatorIndex >= 0) - { - string key = line.Substring(0, separatorIndex).Trim(); - if (key == "name") - { - projectName = line.Substring(separatorIndex + 1).Trim(); - break; - } - } + EditorUtility.DisplayDialog("Error", + $"Failed to read from existing file {exportFstPath}. Please check the file and try again.", "Ok"); + return; } } catch { - EditorUtility.DisplayDialog("Error", "Failed to read from existing file " + exportFstPath + - ". Please check the file and try again.", "Ok"); + EditorUtility.DisplayDialog("Error", + $"Failed to read from existing file {exportFstPath}. Please check the file and try again.", "Ok"); return; } - string exportModelPath = Path.GetDirectoryName(exportFstPath) + "/" + assetName + ".fbx"; + string exportModelPath = $"{Path.GetDirectoryName(exportFstPath)}/{assetName}.fbx"; if (File.Exists(exportModelPath)) { // 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; // write out a new fst file in place of the old file