From ee0555287c17e6ed1100a7c0c54214571210580a Mon Sep 17 00:00:00 2001 From: Jake Boraman Date: Tue, 6 Aug 2024 14:05:09 +0100 Subject: [PATCH] Fix FBX-to-GR2 obtaining incorrect folder, fix FBX-to-GR2 throwing exceptions when optional folders not found --- Launcher/ToolkitInterface/HRToolkit.cs | 27 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Launcher/ToolkitInterface/HRToolkit.cs b/Launcher/ToolkitInterface/HRToolkit.cs index e12bd4e..d91af3b 100644 --- a/Launcher/ToolkitInterface/HRToolkit.cs +++ b/Launcher/ToolkitInterface/HRToolkit.cs @@ -223,23 +223,30 @@ string getFilepath(string file) void ConvertAllInFolder(string folder) { - IEnumerable files = Directory.EnumerateFiles(folder, "*.fbx"); + try + { + IEnumerable files = Directory.EnumerateFiles(folder, "*.fbx"); - foreach (var f in files) + foreach (var f in files) + { + Task toolTask = GR2FromFBX( + f, + getFilepath(f) + ".json", + getFilepath(f) + ".gr2", + json_rebuild, + show_output); + dispatchedTasks.Add(toolTask); + } + } + catch (DirectoryNotFoundException) { - Task toolTask = GR2FromFBX( - f, - getFilepath(f) + ".json", - getFilepath(f) + ".gr2", - json_rebuild, - show_output); - dispatchedTasks.Add(toolTask); + Trace.WriteLine($"{folder} does not exist"); } } foreach (var folder in Directory.EnumerateDirectories(fbx_search_path)) { - string folderName = Path.GetDirectoryName(folder); + string folderName = Path.GetFileName(folder); string[] assetFolders = new[] { "animations", "collision", "markers", "physics", "render", "skeleton" };