From 87e87cf0ab09c209ee6872eec40e20131117ebe3 Mon Sep 17 00:00:00 2001 From: Razmoth <32140579+Razmoth@users.noreply.github.com> Date: Tue, 30 Jan 2024 20:53:12 +0400 Subject: [PATCH] - [Core] fix bug with export part for `Materials`. --- AssetStudio.CLI/Exporter.cs | 4 ++-- AssetStudio.GUI/Exporter.cs | 8 ++++---- AssetStudio.GUI/MainForm.cs | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/AssetStudio.CLI/Exporter.cs b/AssetStudio.CLI/Exporter.cs index 36044a0..3664154 100644 --- a/AssetStudio.CLI/Exporter.cs +++ b/AssetStudio.CLI/Exporter.cs @@ -375,7 +375,7 @@ namespace AssetStudio.CLI : new ModelConverter(m_Animator, options); if (options.exportMaterials) { - var materialExportPath = Path.Combine(exportFullPath, "Materials"); + var materialExportPath = Path.Combine(Path.GetDirectoryName(exportFullPath), "Materials"); Directory.CreateDirectory(materialExportPath); foreach (var material in options.materials) { @@ -393,7 +393,7 @@ namespace AssetStudio.CLI return false; var m_GameObject = (GameObject)item.Asset; - return ExportGameObject(m_GameObject, exportPath, animationList); + return ExportGameObject(m_GameObject, exportFullPath, animationList); } public static bool ExportGameObject(GameObject gameObject, string exportPath, List animationList = null) diff --git a/AssetStudio.GUI/Exporter.cs b/AssetStudio.GUI/Exporter.cs index 398a521..1d14c32 100644 --- a/AssetStudio.GUI/Exporter.cs +++ b/AssetStudio.GUI/Exporter.cs @@ -374,7 +374,7 @@ namespace AssetStudio.GUI : new ModelConverter(m_Animator, options); if (options.exportMaterials) { - var materialExportPath = Path.Combine(exportFullPath, "Materials"); + var materialExportPath = Path.Combine(Path.GetDirectoryName(exportFullPath), "Materials"); Directory.CreateDirectory(materialExportPath); foreach (var material in options.materials) { @@ -404,8 +404,8 @@ namespace AssetStudio.GUI collectAnimations = Properties.Settings.Default.collectAnimations, exportMaterials = Properties.Settings.Default.exportMaterials, materials = new HashSet(), - uvs = JsonConvert.DeserializeObject>(Properties.Settings.Default.uvs, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Populate }), - texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Populate }), + uvs = JsonConvert.DeserializeObject>(Properties.Settings.Default.uvs), + texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), }; var convert = animationList != null ? new ModelConverter(gameObject, options, animationList.Select(x => (AnimationClip)x.Asset).ToArray()) @@ -449,7 +449,7 @@ namespace AssetStudio.GUI : new ModelConverter(rootName, gameObject, options); if (options.exportMaterials) { - var materialExportPath = Path.Combine(exportPath, "Materials"); + var materialExportPath = Path.Combine(Path.GetDirectoryName(exportPath), "Materials"); Directory.CreateDirectory(materialExportPath); foreach (var material in options.materials) { diff --git a/AssetStudio.GUI/MainForm.cs b/AssetStudio.GUI/MainForm.cs index eb3b897..f5b91fe 100644 --- a/AssetStudio.GUI/MainForm.cs +++ b/AssetStudio.GUI/MainForm.cs @@ -1698,6 +1698,11 @@ namespace AssetStudio.GUI saveDirectoryBackup = saveFolderDialog.Folder; var exportPath = Path.Combine(saveFolderDialog.Folder, "GameObject") + Path.DirectorySeparatorChar; var roots = sceneTreeView.Nodes.Cast().Where(x => x.Level == 0 && x.Checked).ToList(); + if (roots.Count == 0) + { + Logger.Info("No root nodes found selected."); + return; + } List animationList = null; if (animation) {