continue work

This commit is contained in:
Perfare 2018-10-17 01:51:25 +08:00
parent 17bd7a210a
commit 21a8d7ef49
6 changed files with 61 additions and 50 deletions

View File

@ -584,7 +584,7 @@ namespace AssetStudio
{ {
int xdiff = reverseSort ? b.Text.CompareTo(a.Text) : a.Text.CompareTo(b.Text); int xdiff = reverseSort ? b.Text.CompareTo(a.Text) : a.Text.CompareTo(b.Text);
if (xdiff != 0) return xdiff; if (xdiff != 0) return xdiff;
return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.fullSize.CompareTo(b.fullSize); return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.FullSize.CompareTo(b.FullSize);
}); });
break; break;
case 1: case 1:
@ -592,13 +592,13 @@ namespace AssetStudio
{ {
int xdiff = reverseSort ? b.TypeString.CompareTo(a.TypeString) : a.TypeString.CompareTo(b.TypeString); int xdiff = reverseSort ? b.TypeString.CompareTo(a.TypeString) : a.TypeString.CompareTo(b.TypeString);
if (xdiff != 0) return xdiff; if (xdiff != 0) return xdiff;
return secondSortColumn == 2 ? a.fullSize.CompareTo(b.fullSize) : a.Text.CompareTo(b.Text); return secondSortColumn == 2 ? a.FullSize.CompareTo(b.FullSize) : a.Text.CompareTo(b.Text);
}); });
break; break;
case 2: case 2:
visibleAssets.Sort(delegate (AssetPreloadData a, AssetPreloadData b) visibleAssets.Sort(delegate (AssetPreloadData a, AssetPreloadData b)
{ {
int xdiff = reverseSort ? b.fullSize.CompareTo(a.fullSize) : a.fullSize.CompareTo(b.fullSize); int xdiff = reverseSort ? b.FullSize.CompareTo(a.FullSize) : a.FullSize.CompareTo(b.FullSize);
if (xdiff != 0) return xdiff; if (xdiff != 0) return xdiff;
return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.Text.CompareTo(b.Text); return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.Text.CompareTo(b.Text);
}); });

View File

@ -1,4 +1,5 @@
using System.Linq; using System;
using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
@ -6,19 +7,38 @@ namespace AssetStudio
{ {
public class AssetPreloadData : ListViewItem public class AssetPreloadData : ListViewItem
{ {
public AssetsFile sourceFile;
public long m_PathID; public long m_PathID;
public uint Offset; public uint Offset;
public int Size; public uint Size;
public ClassIDType Type; public long FullSize;
public int typeID;
public int classID;
public SerializedType serializedType; public SerializedType serializedType;
public ClassIDType Type;
public string TypeString; public string TypeString;
public int fullSize;
public string InfoText; public string InfoText;
public AssetsFile sourceFile;
public GameObject gameObject;
public string uniqueID; public string uniqueID;
public GameObject gameObject;
public AssetPreloadData(AssetsFile assetsFile, ObjectInfo objectInfo, string uniqueID)
{
sourceFile = assetsFile;
m_PathID = objectInfo.m_PathID;
Offset = objectInfo.byteStart;
Size = objectInfo.byteSize;
FullSize = objectInfo.byteSize;
serializedType = objectInfo.serializedType;
if (Enum.IsDefined(typeof(ClassIDType), objectInfo.classID))
{
Type = (ClassIDType)objectInfo.classID;
TypeString = Type.ToString();
}
else
{
Type = ClassIDType.UnknownType;
TypeString = $"UnknownType {objectInfo.classID}";
}
this.uniqueID = uniqueID;
}
public EndianBinaryReader InitReader() public EndianBinaryReader InitReader()
{ {

View File

@ -88,7 +88,7 @@ namespace AssetStudio
m_Types = new List<SerializedType>(typeCount); m_Types = new List<SerializedType>(typeCount);
for (int i = 0; i < typeCount; i++) for (int i = 0; i < typeCount; i++)
{ {
m_Types.Add(ReadSerializedType());; m_Types.Add(ReadSerializedType());
} }
if (header.m_Version >= 7 && header.m_Version < 14) if (header.m_Version >= 7 && header.m_Version < 14)
@ -99,66 +99,53 @@ namespace AssetStudio
//Read Objects //Read Objects
int objectCount = reader.ReadInt32(); int objectCount = reader.ReadInt32();
string assetIDfmt = "D" + objectCount.ToString().Length; //format for unique ID var assetIDfmt = "D" + objectCount.ToString().Length; //format for unique ID
m_Objects = new Dictionary<long, ObjectInfo>(objectCount);
for (int i = 0; i < objectCount; i++) for (int i = 0; i < objectCount; i++)
{ {
AssetPreloadData asset = new AssetPreloadData(); var objectInfo = new ObjectInfo();
if (header.m_Version < 14) if (header.m_Version < 14)
{ {
asset.m_PathID = reader.ReadInt32(); objectInfo.m_PathID = reader.ReadInt32();
} }
else else
{ {
reader.AlignStream(4); reader.AlignStream(4);
asset.m_PathID = reader.ReadInt64(); objectInfo.m_PathID = reader.ReadInt64();
} }
asset.Offset = reader.ReadUInt32(); objectInfo.byteStart = reader.ReadUInt32();
asset.Offset += header.m_DataOffset; objectInfo.byteStart += header.m_DataOffset;
asset.Size = reader.ReadInt32(); objectInfo.byteSize = reader.ReadUInt32();
asset.typeID = reader.ReadInt32(); objectInfo.typeID = reader.ReadInt32();
if (header.m_Version < 16) if (header.m_Version < 16)
{ {
asset.classID = reader.ReadUInt16(); objectInfo.classID = reader.ReadUInt16();
asset.serializedType = m_Types.Find(x => x.classID == asset.typeID); objectInfo.serializedType = m_Types.Find(x => x.classID == objectInfo.typeID);
reader.Position += 2; objectInfo.isDestroyed = reader.ReadUInt16();
} }
else else
{ {
var type = m_Types[asset.typeID]; var type = m_Types[objectInfo.typeID];
asset.serializedType = type; objectInfo.serializedType = type;
asset.classID = type.classID; objectInfo.classID = type.classID;
} }
if (header.m_Version == 15 || header.m_Version == 16) if (header.m_Version == 15 || header.m_Version == 16)
{ {
var stripped = reader.ReadByte(); var stripped = reader.ReadByte();
} }
m_Objects.Add(objectInfo.m_PathID, objectInfo);
if (Enum.IsDefined(typeof(ClassIDType), asset.classID)) //Create AssetPreloadData
{ var asset = new AssetPreloadData(this, objectInfo, i.ToString(assetIDfmt));
asset.Type = (ClassIDType)asset.classID;
asset.TypeString = asset.Type.ToString();
}
else
{
asset.Type = ClassIDType.UnknownType;
asset.TypeString = $"UnknownType {asset.classID}";
}
asset.uniqueID = i.ToString(assetIDfmt);
asset.fullSize = asset.Size;
asset.sourceFile = this;
preloadTable.Add(asset.m_PathID, asset); preloadTable.Add(asset.m_PathID, asset);
#region read BuildSettings to get version for version 2.x files #region read BuildSettings to get version for version 2.x files
if (asset.Type == ClassIDType.BuildSettings && header.m_Version == 6) if (asset.Type == ClassIDType.BuildSettings && header.m_Version == 6)
{ {
long nextAsset = reader.Position; var nextAsset = reader.Position;
BuildSettings BSettings = new BuildSettings(asset); var BSettings = new BuildSettings(asset);
unityVersion = BSettings.m_Version; unityVersion = BSettings.m_Version;
reader.Position = nextAsset; reader.Position = nextAsset;

View File

@ -276,7 +276,7 @@ namespace AssetStudio
var exportFullName = exportPath + asset.Text + ".dat"; var exportFullName = exportPath + asset.Text + ".dat";
if (ExportFileExists(exportFullName)) if (ExportFileExists(exportFullName))
return false; return false;
var bytes = asset.InitReader().ReadBytes(asset.Size); var bytes = asset.InitReader().ReadBytes((int)asset.Size);
File.WriteAllBytes(exportFullName, bytes); File.WriteAllBytes(exportFullName, bytes);
return true; return true;
} }

View File

@ -12,5 +12,9 @@ namespace AssetStudio
public int typeID; public int typeID;
public int classID; public int classID;
public ushort isDestroyed; public ushort isDestroyed;
//custom
public long m_PathID;
public SerializedType serializedType;
} }
} }

View File

@ -201,21 +201,21 @@ namespace AssetStudio
{ {
var m_Texture2D = new Texture2D(asset, false); var m_Texture2D = new Texture2D(asset, false);
if (!string.IsNullOrEmpty(m_Texture2D.path)) if (!string.IsNullOrEmpty(m_Texture2D.path))
asset.fullSize = asset.Size + (int)m_Texture2D.size; asset.FullSize = asset.Size + m_Texture2D.size;
goto case ClassIDType.NamedObject; goto case ClassIDType.NamedObject;
} }
case ClassIDType.AudioClip: case ClassIDType.AudioClip:
{ {
var m_AudioClip = new AudioClip(asset, false); var m_AudioClip = new AudioClip(asset, false);
if (!string.IsNullOrEmpty(m_AudioClip.m_Source)) if (!string.IsNullOrEmpty(m_AudioClip.m_Source))
asset.fullSize = asset.Size + (int)m_AudioClip.m_Size; asset.FullSize = asset.Size + m_AudioClip.m_Size;
goto case ClassIDType.NamedObject; goto case ClassIDType.NamedObject;
} }
case ClassIDType.VideoClip: case ClassIDType.VideoClip:
{ {
var m_VideoClip = new VideoClip(asset, false); var m_VideoClip = new VideoClip(asset, false);
if (!string.IsNullOrEmpty(m_VideoClip.m_OriginalPath)) if (!string.IsNullOrEmpty(m_VideoClip.m_OriginalPath))
asset.fullSize = asset.Size + (int)m_VideoClip.m_Size; asset.FullSize = asset.Size + (long)m_VideoClip.m_Size;
goto case ClassIDType.NamedObject; goto case ClassIDType.NamedObject;
} }
case ClassIDType.NamedObject: case ClassIDType.NamedObject:
@ -280,7 +280,7 @@ namespace AssetStudio
{ {
asset.Text = asset.TypeString + " #" + asset.uniqueID; asset.Text = asset.TypeString + " #" + asset.uniqueID;
} }
asset.SubItems.AddRange(new[] { asset.TypeString, asset.fullSize.ToString() }); asset.SubItems.AddRange(new[] { asset.TypeString, asset.FullSize.ToString() });
//处理同名文件 //处理同名文件
if (!assetsNameHash.Add((asset.TypeString + asset.Text).ToUpper())) if (!assetsNameHash.Add((asset.TypeString + asset.Text).ToUpper()))
{ {