use list to store objects in their original order

This commit is contained in:
Perfare 2020-03-28 14:13:25 +08:00
parent c4270e186d
commit e1dc54d6d7
4 changed files with 16 additions and 8 deletions

View File

@ -244,7 +244,6 @@ namespace AssetStudio
Progress.Reset();
foreach (var assetsFile in assetsFileList)
{
assetsFile.Objects = new Dictionary<long, Object>(assetsFile.m_Objects.Count);
foreach (var objectInfo in assetsFile.m_Objects)
{
var objectReader = new ObjectReader(assetsFile.reader, assetsFile, objectInfo);
@ -338,7 +337,7 @@ namespace AssetStudio
obj = new Object(objectReader);
break;
}
assetsFile.Objects.Add(objectInfo.m_PathID, obj);
assetsFile.AddObject(obj);
}
catch (Exception e)
{
@ -362,7 +361,7 @@ namespace AssetStudio
foreach (var assetsFile in assetsFileList)
{
foreach (var obj in assetsFile.Objects.Values)
foreach (var obj in assetsFile.Objects)
{
if (obj is GameObject m_GameObject)
{

View File

@ -57,7 +57,7 @@ namespace AssetStudio
{
if (TryGetAssetsFile(out var sourceFile))
{
if (sourceFile.Objects.TryGetValue(m_PathID, out var obj))
if (sourceFile.ObjectsDic.TryGetValue(m_PathID, out var obj))
{
if (obj is T variable)
{
@ -75,7 +75,7 @@ namespace AssetStudio
{
if (TryGetAssetsFile(out var sourceFile))
{
if (sourceFile.Objects.TryGetValue(m_PathID, out var obj))
if (sourceFile.ObjectsDic.TryGetValue(m_PathID, out var obj))
{
if (obj is T2 variable)
{

View File

@ -15,7 +15,8 @@ namespace AssetStudio
public string fileName;
public int[] version = { 0, 0, 0, 0 };
public BuildType buildType;
public Dictionary<long, Object> Objects;
public List<Object> Objects;
public Dictionary<long, Object> ObjectsDic;
public SerializedFileHeader header;
private EndianType m_FileEndianess;
@ -100,6 +101,8 @@ namespace AssetStudio
//ReadObjects
int objectCount = reader.ReadInt32();
m_Objects = new List<ObjectInfo>(objectCount);
Objects = new List<Object>(objectCount);
ObjectsDic = new Dictionary<long, Object>(objectCount);
for (int i = 0; i < objectCount; i++)
{
var objectInfo = new ObjectInfo();
@ -331,6 +334,12 @@ namespace AssetStudio
}
}
public void AddObject(Object obj)
{
Objects.Add(obj);
ObjectsDic.Add(obj.m_PathID, obj);
}
public static bool IsSerializedFile(EndianBinaryReader reader)
{
var fileSize = reader.BaseStream.Length;

View File

@ -110,7 +110,7 @@ namespace AssetStudioGUI
{
var tempExportableAssets = new List<AssetItem>();
Dictionary<long, string> containers = null;
foreach (var asset in assetsFile.Objects.Values)
foreach (var asset in assetsFile.Objects)
{
var assetItem = new AssetItem(asset);
objectAssetItemDic.Add(asset, assetItem);
@ -230,7 +230,7 @@ namespace AssetStudioGUI
{
var fileNode = new GameObjectTreeNode(assetsFile.fileName); //RootNode
foreach (var obj in assetsFile.Objects.Values)
foreach (var obj in assetsFile.Objects)
{
if (obj is GameObject m_GameObject)
{