From 4e93ea5a82586252e1c2fe9e3d02b88d45937673 Mon Sep 17 00:00:00 2001 From: VaDiM Date: Mon, 16 Dec 2024 01:25:11 +0300 Subject: [PATCH] Improve ExportRaw option - External data will also be added to exported assets --- AssetStudioCLI/Exporter.cs | 21 +++++++++++++++++++++ AssetStudioGUI/Exporter.cs | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/AssetStudioCLI/Exporter.cs b/AssetStudioCLI/Exporter.cs index 5751daf..83c6eb0 100644 --- a/AssetStudioCLI/Exporter.cs +++ b/AssetStudioCLI/Exporter.cs @@ -160,6 +160,27 @@ namespace AssetStudioCLI { if (!TryExportFile(exportPath, item, ".dat", out var exportFullPath, mode: "ExportRaw")) return false; + switch (item.Asset) + { + case Texture2D m_Texture2D: + if (!string.IsNullOrEmpty(m_Texture2D.m_StreamData?.path)) + { + File.WriteAllBytes(exportFullPath.Replace(".dat", "_data.dat"), m_Texture2D.image_data.GetData()); + } + break; + case AudioClip m_AudioClip: + if (!string.IsNullOrEmpty(m_AudioClip.m_Source)) + { + File.WriteAllBytes(exportFullPath.Replace(".dat", "_data.dat"), m_AudioClip.m_AudioData.GetData()); + } + break; + case VideoClip m_VideoClip: + if (!string.IsNullOrEmpty(m_VideoClip.m_ExternalResources.m_Source)) + { + File.WriteAllBytes(exportFullPath.Replace(".dat", "_data.dat"), m_VideoClip.m_VideoData.GetData()); + } + break; + } File.WriteAllBytes(exportFullPath, item.Asset.GetRawData()); Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); diff --git a/AssetStudioGUI/Exporter.cs b/AssetStudioGUI/Exporter.cs index b638c36..a6f27a2 100644 --- a/AssetStudioGUI/Exporter.cs +++ b/AssetStudioGUI/Exporter.cs @@ -187,6 +187,27 @@ namespace AssetStudioGUI { if (!TryExportFile(exportPath, item, ".dat", out var exportFullPath, mode: "ExportRaw")) return false; + switch (item.Asset) + { + case Texture2D m_Texture2D: + if (!string.IsNullOrEmpty(m_Texture2D.m_StreamData?.path)) + { + File.WriteAllBytes(exportFullPath.Replace(".dat", "_data.dat"), m_Texture2D.image_data.GetData()); + } + break; + case AudioClip m_AudioClip: + if (!string.IsNullOrEmpty(m_AudioClip.m_Source)) + { + File.WriteAllBytes(exportFullPath.Replace(".dat", "_data.dat"), m_AudioClip.m_AudioData.GetData()); + } + break; + case VideoClip m_VideoClip: + if (!string.IsNullOrEmpty(m_VideoClip.m_ExternalResources.m_Source)) + { + File.WriteAllBytes(exportFullPath.Replace(".dat", "_data.dat"), m_VideoClip.m_VideoData.GetData()); + } + break; + } File.WriteAllBytes(exportFullPath, item.Asset.GetRawData()); return true; }