Move BuildType to UnityVersion class

This commit is contained in:
VaDiM 2024-09-25 23:40:22 +03:00
parent fa332b45df
commit 5a84a67955
7 changed files with 17 additions and 28 deletions

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AssetStudio
{
public class BuildType
{
private string buildType;
public BuildType(string type)
{
buildType = type;
}
public bool IsAlpha => buildType == "a";
public bool IsPatch => buildType == "p";
}
}

View File

@ -546,7 +546,7 @@ namespace AssetStudio
//Unity fixed it in 2017.3.1p1 and later versions //Unity fixed it in 2017.3.1p1 and later versions
if (version >= (2017, 4) //2017.4 if (version >= (2017, 4) //2017.4
|| version == (2017, 3, 1) && buildType.IsPatch //fixed after 2017.3.1px || version == (2017, 3, 1) && version.IsPatch //fixed after 2017.3.1px
|| version == (2017, 3) && m_MeshCompression == 0)//2017.3.xfx with no compression || version == (2017, 3) && m_MeshCompression == 0)//2017.3.xfx with no compression
{ {
var m_IndexFormat = reader.ReadInt32(); var m_IndexFormat = reader.ReadInt32();

View File

@ -14,7 +14,6 @@ namespace AssetStudio
public long m_PathID; public long m_PathID;
[JsonIgnore] [JsonIgnore]
public UnityVersion version; public UnityVersion version;
protected BuildType buildType;
[JsonIgnore] [JsonIgnore]
public BuildTarget platform; public BuildTarget platform;
[JsonConverter(typeof(JsonStringEnumConverter))] [JsonConverter(typeof(JsonStringEnumConverter))]
@ -48,7 +47,6 @@ namespace AssetStudio
type = reader.type; type = reader.type;
m_PathID = reader.m_PathID; m_PathID = reader.m_PathID;
version = reader.version; version = reader.version;
buildType = reader.buildType;
platform = reader.platform; platform = reader.platform;
serializedType = reader.serializedType; serializedType = reader.serializedType;
classID = reader.classID; classID = reader.classID;

View File

@ -214,7 +214,7 @@ namespace AssetStudio
m_PixelsToUnits = reader.ReadSingle(); m_PixelsToUnits = reader.ReadSingle();
if (version >= (5, 4, 2) if (version >= (5, 4, 2)
|| version == (5, 4, 1) && buildType.IsPatch && version.Build >= 3) //5.4.1p3 and up || version == (5, 4, 1) && version.IsPatch && version.Build >= 3) //5.4.1p3 and up
{ {
m_Pivot = reader.ReadVector2(); m_Pivot = reader.ReadVector2();
} }

View File

@ -15,7 +15,6 @@ namespace AssetStudio
public SerializedFileFormatVersion m_Version; public SerializedFileFormatVersion m_Version;
public UnityVersion version => assetsFile.version; public UnityVersion version => assetsFile.version;
public BuildType buildType => assetsFile.buildType;
public ObjectReader(EndianBinaryReader reader, SerializedFile assetsFile, ObjectInfo objectInfo) : base(reader.BaseStream, reader.Endian) public ObjectReader(EndianBinaryReader reader, SerializedFile assetsFile, ObjectInfo objectInfo) : base(reader.BaseStream, reader.Endian)
{ {

View File

@ -14,7 +14,6 @@ namespace AssetStudio
public string originalPath; public string originalPath;
public string fileName; public string fileName;
public UnityVersion version = new UnityVersion(); public UnityVersion version = new UnityVersion();
public BuildType buildType;
public List<Object> Objects; public List<Object> Objects;
public Dictionary<long, Object> ObjectsDic; public Dictionary<long, Object> ObjectsDic;
@ -222,7 +221,6 @@ namespace AssetStudio
if (unityVer != null && !unityVer.IsStripped) if (unityVer != null && !unityVer.IsStripped)
{ {
unityVersion = unityVer.FullVersion; unityVersion = unityVer.FullVersion;
buildType = new BuildType(unityVer.BuildType);
version = unityVer; version = unityVer;
} }
} }

View File

@ -4,6 +4,16 @@ using System.Text.RegularExpressions;
namespace AssetStudio namespace AssetStudio
{ {
public static class BuildTypes
{
public static readonly string
Alpha = "a",
Beta = "b",
Final = "f",
Patch = "p",
Tuanjie = "t";
}
public class UnityVersion : IComparable public class UnityVersion : IComparable
{ {
public int Major { get; } public int Major { get; }
@ -14,6 +24,10 @@ namespace AssetStudio
public string FullVersion { get; } public string FullVersion { get; }
public bool IsStripped => this == (0, 0, 0); public bool IsStripped => this == (0, 0, 0);
public bool IsAlpha => BuildType == BuildTypes.Alpha;
public bool IsBeta => BuildType == BuildTypes.Beta;
public bool IsPatch => BuildType == BuildTypes.Patch;
public bool IsTuanjie => BuildType == BuildTypes.Tuanjie;
public UnityVersion(string version) public UnityVersion(string version)
{ {
@ -47,7 +61,7 @@ namespace AssetStudio
if (!IsStripped) if (!IsStripped)
{ {
Build = 1; Build = 1;
BuildType = "f"; BuildType = BuildTypes.Final;
FullVersion += $"{BuildType}{Build}"; FullVersion += $"{BuildType}{Build}";
} }
} }