Raplace Unity ver array with Unity ver class

This commit is contained in:
VaDiM
2024-03-30 14:19:54 +03:00
parent c9e9bc840c
commit 3cc6bed844
39 changed files with 830 additions and 341 deletions

View File

@ -105,7 +105,7 @@ namespace AssetStudio
public string GetExtensionName()
{
if (m_AudioClip.version[0] < 5)
if (m_AudioClip.version < 5)
{
switch (m_AudioClip.m_Type)
{
@ -170,7 +170,7 @@ namespace AssetStudio
{
public static bool IsConvertSupport(this AudioClip m_AudioClip)
{
if (m_AudioClip.version[0] < 5)
if (m_AudioClip.version < 5)
{
switch (m_AudioClip.m_Type)
{

View File

@ -4,9 +4,9 @@ namespace AssetStudio
{
public class SerializedTypeHelper
{
private readonly int[] version;
private readonly UnityVersion version;
public SerializedTypeHelper(int[] version)
public SerializedTypeHelper(UnityVersion version)
{
this.version = version;
}
@ -24,7 +24,7 @@ namespace AssetStudio
{
nodes.Add(new TypeTreeNode($"PPtr<{type}>", name, indent, false));
nodes.Add(new TypeTreeNode("int", "m_FileID", indent + 1, false));
if (version[0] >= 5) //5.0 and up
if (version >= 5) //5.0 and up
{
nodes.Add(new TypeTreeNode("SInt64", "m_PathID", indent + 1, false));
}
@ -58,7 +58,7 @@ namespace AssetStudio
nodes.Add(new TypeTreeNode("float", "value", indent + 4, false));
nodes.Add(new TypeTreeNode("float", "inSlope", indent + 4, false));
nodes.Add(new TypeTreeNode("float", "outSlope", indent + 4, false));
if (version[0] >= 2018) //2018 and up
if (version >= 2018) //2018 and up
{
nodes.Add(new TypeTreeNode("int", "weightedMode", indent + 4, false));
nodes.Add(new TypeTreeNode("float", "inWeight", indent + 4, false));
@ -66,7 +66,7 @@ namespace AssetStudio
}
nodes.Add(new TypeTreeNode("int", "m_PreInfinity", indent + 1, false));
nodes.Add(new TypeTreeNode("int", "m_PostInfinity", indent + 1, false));
if (version[0] > 5 || (version[0] == 5 && version[1] >= 3)) //5.3 and up
if (version >= (5, 3)) //5.3 and up
{
nodes.Add(new TypeTreeNode("int", "m_RotationOrder", indent + 1, false));
}
@ -75,7 +75,7 @@ namespace AssetStudio
public void AddGradient(List<TypeTreeNode> nodes, string name, int indent)
{
nodes.Add(new TypeTreeNode("Gradient", name, indent, false));
if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up
if (version >= (5, 6)) //5.6 and up
{
AddColorRGBA(nodes, "key0", indent + 1);
AddColorRGBA(nodes, "key1", indent + 1);
@ -113,7 +113,7 @@ namespace AssetStudio
nodes.Add(new TypeTreeNode("UInt16", "atime5", indent + 1, false));
nodes.Add(new TypeTreeNode("UInt16", "atime6", indent + 1, false));
nodes.Add(new TypeTreeNode("UInt16", "atime7", indent + 1, false));
if (version[0] > 5 || (version[0] == 5 && version[1] >= 5)) //5.5 and up
if (version >= (5, 5)) //5.5 and up
{
nodes.Add(new TypeTreeNode("int", "m_Mode", indent + 1, false));
}
@ -134,7 +134,7 @@ namespace AssetStudio
AddGUIStyleState(nodes, "m_OnActive", indent + 1);
AddGUIStyleState(nodes, "m_OnFocused", indent + 1);
AddRectOffset(nodes, "m_Border", indent + 1);
if (version[0] >= 4) //4 and up
if (version >= 4) //4 and up
{
AddRectOffset(nodes, "m_Margin", indent + 1);
AddRectOffset(nodes, "m_Padding", indent + 1);
@ -146,7 +146,7 @@ namespace AssetStudio
}
AddRectOffset(nodes, "m_Overflow", indent + 1);
AddPPtr(nodes, "Font", "m_Font", indent + 1);
if (version[0] >= 4) //4 and up
if (version >= 4) //4 and up
{
nodes.Add(new TypeTreeNode("int", "m_FontSize", indent + 1, false));
nodes.Add(new TypeTreeNode("int", "m_FontStyle", indent + 1, false));
@ -171,7 +171,7 @@ namespace AssetStudio
AddVector2f(nodes, "m_ClipOffset", indent + 1);
nodes.Add(new TypeTreeNode("float", "m_FixedWidth", indent + 1, false));
nodes.Add(new TypeTreeNode("float", "m_FixedHeight", indent + 1, false));
if (version[0] >= 3) //3 and up
if (version >= 3) //3 and up
{
nodes.Add(new TypeTreeNode("int", "m_FontSize", indent + 1, false));
nodes.Add(new TypeTreeNode("int", "m_FontStyle", indent + 1, false));

View File

@ -871,11 +871,11 @@ namespace AssetStudio
public int Length;
public int Segment;
public ShaderSubProgramEntry(BinaryReader reader, int[] version)
public ShaderSubProgramEntry(BinaryReader reader, UnityVersion version)
{
Offset = reader.ReadInt32();
Length = reader.ReadInt32();
if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up
if (version >= (2019, 3)) //2019.3 and up
{
Segment = reader.ReadInt32();
}
@ -887,7 +887,7 @@ namespace AssetStudio
public ShaderSubProgramEntry[] entries;
public ShaderSubProgram[] m_SubPrograms;
public ShaderProgram(BinaryReader reader, int[] version)
public ShaderProgram(BinaryReader reader, UnityVersion version)
{
var subProgramsCapacity = reader.ReadInt32();
entries = new ShaderSubProgramEntry[subProgramsCapacity];

View File

@ -13,7 +13,7 @@ namespace AssetStudio
private int m_HeightCrop;
private TextureFormat m_TextureFormat;
private byte[] m_PlatformBlob;
private int[] version;
private UnityVersion version;
private BuildTarget platform;
private int outPutDataSize;
@ -748,7 +748,7 @@ namespace AssetStudio
private bool UnpackCrunch(byte[] image_data, out byte[] result)
{
if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3) //2017.3 and up
if (version >= (2017, 3) //2017.3 and up
|| m_TextureFormat == TextureFormat.ETC_RGB4Crunched
|| m_TextureFormat == TextureFormat.ETC2_RGBA8Crunched)
{