Improve ExportRaw option

- External data will also be added to exported assets
This commit is contained in:
VaDiM 2024-12-16 01:25:11 +03:00
parent 6608e76471
commit 4e93ea5a82
2 changed files with 42 additions and 0 deletions

View File

@ -160,6 +160,27 @@ namespace AssetStudioCLI
{ {
if (!TryExportFile(exportPath, item, ".dat", out var exportFullPath, mode: "ExportRaw")) if (!TryExportFile(exportPath, item, ".dat", out var exportFullPath, mode: "ExportRaw"))
return false; 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()); File.WriteAllBytes(exportFullPath, item.Asset.GetRawData());
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");

View File

@ -187,6 +187,27 @@ namespace AssetStudioGUI
{ {
if (!TryExportFile(exportPath, item, ".dat", out var exportFullPath, mode: "ExportRaw")) if (!TryExportFile(exportPath, item, ".dat", out var exportFullPath, mode: "ExportRaw"))
return false; 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()); File.WriteAllBytes(exportFullPath, item.Asset.GetRawData());
return true; return true;
} }