Fixes for Unity version parser

This commit is contained in:
VaDiM 2024-09-27 16:43:06 +03:00
parent 5a84a67955
commit c93d27d9a4
5 changed files with 14 additions and 23 deletions

View File

@ -270,7 +270,7 @@ namespace AssetStudio
assetsFile.originalPath = originalPath;
if (assetBundleUnityVer != null && assetsFile.header.m_Version < SerializedFileFormatVersion.Unknown_7)
{
assetsFile.SetVersion(assetBundleUnityVer);
assetsFile.version = assetBundleUnityVer;
}
CheckStrippedVersion(assetsFile, assetBundleUnityVer);
assetsFileList.Add(assetsFile);
@ -487,7 +487,7 @@ namespace AssetStudio
}
if (specifiedUnityVersion != null)
{
assetsFile.SetVersion(SpecifyUnityVersion);
assetsFile.version = SpecifyUnityVersion;
}
}

View File

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace AssetStudio
{
@ -19,7 +17,6 @@ namespace AssetStudio
public SerializedFileHeader header;
private byte m_FileEndianess;
public string unityVersion = "2.5.0f5";
public BuildTarget m_TargetPlatform = BuildTarget.UnknownPlatform;
private bool m_EnableTypeTree = true;
public List<SerializedType> m_Types;
@ -71,8 +68,11 @@ namespace AssetStudio
}
if (header.m_Version >= SerializedFileFormatVersion.Unknown_7)
{
unityVersion = reader.ReadStringToNull();
SetVersion(new UnityVersion(unityVersion));
version = new UnityVersion(reader.ReadStringToNull());
}
else
{
version = new UnityVersion(2, 5, 0);
}
if (header.m_Version >= SerializedFileFormatVersion.Unknown_8)
{
@ -216,15 +216,6 @@ namespace AssetStudio
//reader.AlignStream(16);
}
public void SetVersion(UnityVersion unityVer)
{
if (unityVer != null && !unityVer.IsStripped)
{
unityVersion = unityVer.FullVersion;
version = unityVer;
}
}
private SerializedType ReadSerializedType(bool isRefType)
{
var type = new SerializedType();

View File

@ -38,7 +38,7 @@ namespace AssetStudio
{
int[] ver = Regex.Matches(version, @"\d+").Cast<Match>().Select(x => int.Parse(x.Value)).ToArray();
(Major, Minor, Patch) = (ver[0], ver[1], ver[2]);
if (ver.Length == 4)
if (ver.Length >= 4)
Build = ver[3];
FullVersion = version;
}

View File

@ -266,7 +266,7 @@ namespace AssetStudioGUI
var typeMap = await Task.Run(() => BuildClassStructure());
productName = string.IsNullOrEmpty(productName) ? "no productName" : productName;
Text = $"{guiTitle} - {productName} - {assetsManager.assetsFileList[0].unityVersion} - {assetsManager.assetsFileList[0].m_TargetPlatform}";
Text = $"{guiTitle} - {productName} - {assetsManager.assetsFileList[0].version} - {assetsManager.assetsFileList[0].m_TargetPlatform}";
assetListView.VirtualListSize = visibleAssets.Count;
@ -278,7 +278,7 @@ namespace AssetStudioGUI
classesListView.BeginUpdate();
foreach (var version in typeMap)
{
var versionGroup = new ListViewGroup(version.Key);
var versionGroup = new ListViewGroup(version.Key.FullVersion);
classesListView.Groups.Add(versionGroup);
foreach (var uclass in version.Value)

View File

@ -429,12 +429,12 @@ namespace AssetStudioGUI
return (productName, treeNodeCollection);
}
public static Dictionary<string, SortedDictionary<int, TypeTreeItem>> BuildClassStructure()
public static Dictionary<UnityVersion, SortedDictionary<int, TypeTreeItem>> BuildClassStructure()
{
var typeMap = new Dictionary<string, SortedDictionary<int, TypeTreeItem>>();
var typeMap = new Dictionary<UnityVersion, SortedDictionary<int, TypeTreeItem>>();
foreach (var assetsFile in assetsManager.assetsFileList)
{
if (typeMap.TryGetValue(assetsFile.unityVersion, out var curVer))
if (typeMap.TryGetValue(assetsFile.version, out var curVer))
{
foreach (var type in assetsFile.m_Types.Where(x => x.m_Type != null))
{
@ -458,7 +458,7 @@ namespace AssetStudioGUI
}
items[key] = new TypeTreeItem(key, type.m_Type);
}
typeMap.Add(assetsFile.unityVersion, items);
typeMap.Add(assetsFile.version, items);
}
}
return typeMap;