Improve support for some older Unity versions (<3.0)

- Fix export of AudioClip assets from unity v2.5 and earlier
- Fix parsing of PlayerSettings assets from unity v2.6 and earlier
- Fix parsing of AnimationClip assets from unity v2.5 and earlier
This commit is contained in:
VaDiM
2024-10-04 01:29:38 +03:00
parent c93d27d9a4
commit 58ee2b8f1e
7 changed files with 180 additions and 90 deletions

View File

@@ -984,14 +984,18 @@ namespace AssetStudio
public AnimationEvent(ObjectReader reader)
{
var version = reader.version;
time = reader.ReadSingle();
functionName = reader.ReadAlignedString();
data = reader.ReadAlignedString();
objectReferenceParameter = new PPtr<Object>(reader);
floatParameter = reader.ReadSingle();
if (reader.version >= 3) //3 and up
if (version >= (2, 6)) //2.6 and up
{
intParameter = reader.ReadInt32();
objectReferenceParameter = new PPtr<Object>(reader);
floatParameter = reader.ReadSingle();
if (version >= 3) //3 and up
{
intParameter = reader.ReadInt32();
}
}
messageOptions = reader.ReadInt32();
}
@@ -1067,7 +1071,10 @@ namespace AssetStudio
{
m_Legacy = true;
}
m_Compressed = reader.ReadBoolean();
if (version >= (2, 6)) //2.6 and up
{
m_Compressed = reader.ReadBoolean();
}
if (version >= (4, 3))//4.3 and up
{
m_UseHighQualityCurve = reader.ReadBoolean();
@@ -1080,11 +1087,14 @@ namespace AssetStudio
m_RotationCurves[i] = new QuaternionCurve(reader);
}
int numCRCurves = reader.ReadInt32();
m_CompressedRotationCurves = new CompressedAnimationCurve[numCRCurves];
for (int i = 0; i < numCRCurves; i++)
if (version >= (2, 6)) //2.6 and up
{
m_CompressedRotationCurves[i] = new CompressedAnimationCurve(reader);
int numCRCurves = reader.ReadInt32();
m_CompressedRotationCurves = new CompressedAnimationCurve[numCRCurves];
for (int i = 0; i < numCRCurves; i++)
{
m_CompressedRotationCurves[i] = new CompressedAnimationCurve(reader);
}
}
if (version >= (5, 3))//5.3 and up
@@ -1129,7 +1139,10 @@ namespace AssetStudio
}
m_SampleRate = reader.ReadSingle();
m_WrapMode = reader.ReadInt32();
if (version >= (2, 6)) //2.6 and up
{
m_WrapMode = reader.ReadInt32();
}
if (version >= (3, 4)) //3.4 and up
{
m_Bounds = new AABB(reader);

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace AssetStudio
namespace AssetStudio
{
public sealed class AudioClip : NamedObject
{
@@ -36,11 +30,19 @@ namespace AssetStudio
if (version < 5)
{
m_Format = reader.ReadInt32();
m_Type = (FMODSoundType)reader.ReadInt32();
m_3D = reader.ReadBoolean();
m_UseHardware = reader.ReadBoolean();
reader.AlignStream();
if (version >= (2, 6)) //2.6 to 5
{
m_Type = (FMODSoundType)reader.ReadInt32();
m_3D = reader.ReadBoolean();
m_UseHardware = reader.ReadBoolean();
reader.AlignStream();
}
else
{
m_Length = reader.ReadSingle();
m_Frequency = reader.ReadInt32();
m_Channels = m_Format != 0x05 ? m_Format >> 1 : 0;
}
if (version >= (3, 2)) //3.2.0 to 5
{
int m_Stream = reader.ReadInt32();

View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AssetStudio
namespace AssetStudio
{
public sealed class PlayerSettings : Object
{
@@ -12,37 +7,40 @@ namespace AssetStudio
public PlayerSettings(ObjectReader reader) : base(reader)
{
if (version >= (5, 4)) //5.4.0 and up
if (version >= (3, 0))
{
var productGUID = reader.ReadBytes(16);
}
var AndroidProfiler = reader.ReadBoolean();
//bool AndroidFilterTouchesWhenObscured 2017.2 and up
//bool AndroidEnableSustainedPerformanceMode 2018 and up
reader.AlignStream();
int defaultScreenOrientation = reader.ReadInt32();
int targetDevice = reader.ReadInt32();
if (version < (5, 3)) //5.3 down
{
if (version < 5) //5.0 down
if (version >= (5, 4)) //5.4.0 and up
{
int targetPlatform = reader.ReadInt32(); //4.0 and up targetGlesGraphics
if (version >= (4, 6)) //4.6 and up
{
var targetIOSGraphics = reader.ReadInt32();
}
var productGUID = reader.ReadBytes(16);
}
int targetResolution = reader.ReadInt32();
}
else
{
var useOnDemandResources = reader.ReadBoolean();
var AndroidProfiler = reader.ReadBoolean();
//bool AndroidFilterTouchesWhenObscured 2017.2 and up
//bool AndroidEnableSustainedPerformanceMode 2018 and up
reader.AlignStream();
}
if (version >= (3, 5)) //3.5 and up
{
var accelerometerFrequency = reader.ReadInt32();
int defaultScreenOrientation = reader.ReadInt32();
int targetDevice = reader.ReadInt32();
if (version < (5, 3)) //5.3 down
{
if (version < 5) //5.0 down
{
int targetPlatform = reader.ReadInt32(); //4.0 and up targetGlesGraphics
if (version >= (4, 6)) //4.6 and up
{
var targetIOSGraphics = reader.ReadInt32();
}
}
int targetResolution = reader.ReadInt32();
}
else
{
var useOnDemandResources = reader.ReadBoolean();
reader.AlignStream();
}
if (version >= (3, 5)) //3.5 and up
{
var accelerometerFrequency = reader.ReadInt32();
}
}
companyName = reader.ReadAlignedString();
productName = reader.ReadAlignedString();

View File

@@ -84,13 +84,13 @@ namespace AssetStudio
}
}
public void GetData(byte[] buff)
public void GetData(byte[] buff, int startIndex = 0)
{
var binaryReader = GetReader();
lock (binaryReader)
{
binaryReader.BaseStream.Position = Offset;
binaryReader.Read(buff, 0, (int) size);
binaryReader.Read(buff, startIndex, (int) size);
}
}