Improve support for legacy Unity versions (WIP). Close #103

This commit is contained in:
VaDiM
2026-04-20 03:03:51 +03:00
parent e92d96bb08
commit 36699541fa
39 changed files with 959 additions and 423 deletions
+14 -11
View File
@@ -1,5 +1,6 @@
using AssetStudio;
using AssetStudioCLI.Options;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -92,14 +93,17 @@ namespace AssetStudioCLI
private static bool ExportShader(AssetItem item, string exportPath)
{
if (!TryExportFile(exportPath, item, ".shader", out var exportFullPath))
return false;
var m_Shader = (Shader)item.Asset;
var str = m_Shader.Convert();
File.WriteAllText(exportFullPath, str);
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
return true;
if (item.Asset is Shader m_Shader)
{
if (!TryExportFile(exportPath, item, ".shader", out var exportFullPath))
return false;
var str = m_Shader.Convert();
File.WriteAllText(exportFullPath, str);
Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\"");
return true;
}
return false;
}
private static bool ExportTextAsset(AssetItem item, string exportPath)
@@ -153,11 +157,10 @@ namespace AssetStudioCLI
private static bool ExportFont(AssetItem item, string exportPath)
{
var m_Font = (Font)item.Asset;
if (m_Font.m_FontData != null)
if (item.Asset is Font m_Font && m_Font.m_FontData != null)
{
var extension = ".ttf";
if (m_Font.m_FontData[0] == 79 && m_Font.m_FontData[1] == 84 && m_Font.m_FontData[2] == 84 && m_Font.m_FontData[3] == 79)
if (BinaryPrimitives.ReadInt32LittleEndian(m_Font.m_FontData) == 0x4F54544F) //"OTTO"
{
extension = ".otf";
}