This commit is contained in:
Perfare 2018-11-20 16:47:35 +08:00
parent 8ea998b81f
commit 8c749e21e1
8 changed files with 86 additions and 72 deletions

View File

@ -527,14 +527,13 @@ namespace AssetStudio
public List<StreamedFrame> ReadData()
{
var frameList = new List<StreamedFrame>();
using (Stream stream = new MemoryStream())
var buffer = new byte[data.Length * 4];
Buffer.BlockCopy(data, 0, buffer, 0, buffer.Length);
using (var reader = new BinaryReader(new MemoryStream(buffer)))
{
BinaryWriter writer = new BinaryWriter(stream);
writer.Write(data);
stream.Position = 0;
while (stream.Position < stream.Length)
while (reader.BaseStream.Position < reader.BaseStream.Length)
{
frameList.Add(new StreamedFrame(new BinaryReader(stream)));
frameList.Add(new StreamedFrame(reader));
}
}

View File

@ -5,22 +5,32 @@ using System.Text;
namespace AssetStudio
{
public class AnimationClipOverride
{
public PPtr m_OriginalClip;
public PPtr m_OverrideClip;
public AnimationClipOverride(ObjectReader reader)
{
m_OriginalClip = reader.ReadPPtr();
m_OverrideClip = reader.ReadPPtr();
}
}
public class AnimatorOverrideController : NamedObject
{
public PPtr m_Controller;
public PPtr[][] m_Clips;
public List<AnimationClipOverride> m_Clips;
public AnimatorOverrideController(ObjectReader reader) : base(reader)
{
m_Controller = reader.ReadPPtr();
int numOverrides = reader.ReadInt32();
m_Clips = new PPtr[numOverrides][];
m_Clips = new List<AnimationClipOverride>(numOverrides);
for (int i = 0; i < numOverrides; i++)
{
m_Clips[i] = new PPtr[2];
m_Clips[i][0] = reader.ReadPPtr();
m_Clips[i][1] = reader.ReadPPtr();
m_Clips.Add(new AnimationClipOverride(reader));
}
}
}

View File

@ -5,41 +5,39 @@ using System.Text;
namespace AssetStudio
{
public class AssetInfo
{
public int preloadIndex;
public int preloadSize;
public PPtr asset;
public AssetInfo(ObjectReader reader)
{
preloadIndex = reader.ReadInt32();
preloadSize = reader.ReadInt32();
asset = reader.ReadPPtr();
}
}
public sealed class AssetBundle : NamedObject
{
public class AssetInfo
{
public int preloadIndex;
public int preloadSize;
public PPtr asset;
}
public class ContainerData
{
public string first;
public AssetInfo second;
}
public List<ContainerData> m_Container = new List<ContainerData>();
public List<PPtr> m_PreloadTable;
public List<KeyValuePair<string, AssetInfo>> m_Container;
public AssetBundle(ObjectReader reader) : base(reader)
{
var size = reader.ReadInt32();
for (int i = 0; i < size; i++)
var m_PreloadTableSize = reader.ReadInt32();
m_PreloadTable = new List<PPtr>(m_PreloadTableSize);
for (int i = 0; i < m_PreloadTableSize; i++)
{
reader.ReadPPtr();
m_PreloadTable.Add(reader.ReadPPtr());
}
size = reader.ReadInt32();
for (int i = 0; i < size; i++)
var m_ContainerSize = reader.ReadInt32();
m_Container = new List<KeyValuePair<string, AssetInfo>>(m_ContainerSize);
for (int i = 0; i < m_ContainerSize; i++)
{
var temp = new ContainerData();
temp.first = reader.ReadAlignedString();
temp.second = new AssetInfo();
temp.second.preloadIndex = reader.ReadInt32();
temp.second.preloadSize = reader.ReadInt32();
temp.second.asset = reader.ReadPPtr();
m_Container.Add(temp);
m_Container.Add(new KeyValuePair<string, AssetInfo>(reader.ReadAlignedString(), new AssetInfo(reader)));
}
}
}

View File

@ -110,7 +110,7 @@ namespace AssetStudio
{1057, "int2_storage"},
{1070, "int3_storage"},
{1083, "BoundsInt"},
{1092, "m_CorrespondingSourceObject"}
{1093, "m_CorrespondingSourceObject"}
};
}
}

View File

@ -14,11 +14,6 @@ namespace AssetStudio
}
}
public static void Write(this BinaryWriter writer, uint[] array)
{
WriteArray(writer.Write, array);
}
public static void AlignStream(this BinaryWriter writer, int alignment)
{
var pos = writer.BaseStream.Position;

View File

@ -66,7 +66,7 @@ namespace AssetStudioGUI
//tree search
private int nextGObject;
private List<GameObjectTreeNode> treeSrcResults = new List<GameObjectTreeNode>();
private List<TreeNode> treeSrcResults = new List<TreeNode>();
[DllImport("gdi32.dll")]
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
@ -481,12 +481,9 @@ namespace AssetStudioGUI
{
if (treeSrcResults.Count == 0)
{
foreach (var node in treeNodeDictionary.Values)
foreach (TreeNode node in sceneTreeView.Nodes)
{
if (node.Text.IndexOf(treeSearch.Text, StringComparison.CurrentCultureIgnoreCase) >= 0)
{
treeSrcResults.Add(node);
}
TreeNodeSearch(node);
}
}
if (treeSrcResults.Count > 0)
@ -502,6 +499,19 @@ namespace AssetStudioGUI
}
}
private void TreeNodeSearch(TreeNode treeNode)
{
if (treeNode.Text.IndexOf(treeSearch.Text, StringComparison.CurrentCultureIgnoreCase) >= 0)
{
treeSrcResults.Add(treeNode);
}
foreach (TreeNode node in treeNode.Nodes)
{
TreeNodeSearch(node);
}
}
private void sceneTreeView_AfterCheck(object sender, TreeViewEventArgs e)
{
foreach (TreeNode childNode in e.Node.Nodes)
@ -1701,8 +1711,6 @@ namespace AssetStudioGUI
pair.Value.Dispose();
}
LoadedModuleDic.Clear();
treeNodeDictionary.Clear();
}
private void assetListView_MouseClick(object sender, MouseEventArgs e)
@ -1820,9 +1828,9 @@ namespace AssetStudioGUI
private void jumpToSceneHierarchyToolStripMenuItem_Click(object sender, EventArgs e)
{
var selectasset = (AssetItem)assetListView.Items[assetListView.SelectedIndices[0]];
if (selectasset.gameObject != null)
if (selectasset.TreeNode != null)
{
sceneTreeView.SelectedNode = treeNodeDictionary[selectasset.gameObject];
sceneTreeView.SelectedNode = selectasset.TreeNode;
tabControl1.SelectedTab = tabPage1;
}
}

View File

@ -12,7 +12,7 @@ namespace AssetStudioGUI
public string TypeString;
public string InfoText;
public string UniqueID;
public GameObject gameObject;
public GameObjectTreeNode TreeNode;
public AssetItem(ObjectReader reader)
{

View File

@ -15,11 +15,9 @@ namespace AssetStudioGUI
internal static class Studio
{
public static AssetsManager assetsManager = new AssetsManager();
private static HashSet<string> assetsNameHash = new HashSet<string>();
public static List<AssetItem> exportableAssets = new List<AssetItem>();
public static List<AssetItem> visibleAssets = new List<AssetItem>();
public static Dictionary<string, SortedDictionary<int, TypeTreeItem>> AllTypeMap = new Dictionary<string, SortedDictionary<int, TypeTreeItem>>();
public static Dictionary<GameObject, GameObjectTreeNode> treeNodeDictionary = new Dictionary<GameObject, GameObjectTreeNode>();
public static Dictionary<string, SortedDictionary<int, TypeTreeItem>> AllTypeMap = new Dictionary<string, SortedDictionary<int, TypeTreeItem>>(); //TODO Delete it
public static bool ModuleLoaded;
public static Dictionary<string, ModuleDef> LoadedModuleDic = new Dictionary<string, ModuleDef>();
@ -96,9 +94,10 @@ namespace AssetStudioGUI
public static void BuildAssetList(Dictionary<ObjectReader, AssetItem> tempDic, bool displayAll, bool displayOriginalName, out string productName)
{
productName = string.Empty;
Logger.Info("Building asset list...");
productName = string.Empty;
var assetsNameHash = new HashSet<string>();
var progressCount = assetsManager.assetsFileList.Sum(x => x.ObjectReaders.Count);
int j = 0;
Progress.Reset();
@ -248,17 +247,18 @@ namespace AssetStudioGUI
}
if (displayOriginalName && ab != null)
{
foreach (var x in tempExportableAssets)
foreach (var asset in tempExportableAssets)
{
var replacename = ab.m_Container.Find(y => y.second.asset.m_PathID == x.reader.m_PathID)?.first;
if (!string.IsNullOrEmpty(replacename))
var originalPath = ab.m_Container.Find(y => y.Value.asset.m_PathID == asset.reader.m_PathID).Key;
if (!string.IsNullOrEmpty(originalPath))
{
var ex = Path.GetExtension(replacename);
x.Text = !string.IsNullOrEmpty(ex) ? replacename.Replace(ex, "") : replacename;
if (!assetsNameHash.Add((x.TypeString + x.Text).ToUpper()))
var extension = Path.GetExtension(originalPath);
if (!string.IsNullOrEmpty(extension) && asset.Type == ClassIDType.TextAsset)
{
x.Text = Path.GetDirectoryName(replacename) + "\\" + Path.GetFileNameWithoutExtension(replacename) + x.UniqueID;
//asset.Extension = extension; //TODO
}
asset.Text = Path.GetDirectoryName(originalPath) + "\\" + asset.Text;
}
}
}
@ -277,6 +277,7 @@ namespace AssetStudioGUI
if (gameObjectCount > 0)
{
Logger.Info("Building tree structure...");
var treeNodeDictionary = new Dictionary<GameObject, GameObjectTreeNode>();
int i = 0;
Progress.Reset();
foreach (var assetsFile in assetsManager.assetsFileList)
@ -285,6 +286,12 @@ namespace AssetStudioGUI
foreach (var m_GameObject in assetsFile.GameObjects.Values)
{
if (!treeNodeDictionary.TryGetValue(m_GameObject, out var currentNode))
{
currentNode = new GameObjectTreeNode(m_GameObject);
treeNodeDictionary.Add(m_GameObject, currentNode);
}
foreach (var m_Component in m_GameObject.m_Components)
{
if (m_Component.TryGet(out var asset))
@ -310,7 +317,7 @@ namespace AssetStudioGUI
if (m_MeshFilter.m_Mesh.TryGet(out objectReader))
{
var item = tempDic[objectReader];
item.gameObject = m_GameObject;
item.TreeNode = currentNode;
}
}
break;
@ -324,7 +331,7 @@ namespace AssetStudioGUI
if (m_SkinnedMeshRenderer.m_Mesh.TryGet(out objectReader))
{
var item = tempDic[objectReader];
item.gameObject = m_GameObject;
item.TreeNode = currentNode;
}
}
break;
@ -357,11 +364,6 @@ namespace AssetStudioGUI
}
}
if (!treeNodeDictionary.TryGetValue(m_GameObject, out var currentNode))
{
currentNode = new GameObjectTreeNode(m_GameObject);
treeNodeDictionary.Add(m_GameObject, currentNode);
}
parentNode.Nodes.Add(currentNode);
Progress.Report(++i, gameObjectCount);
@ -372,6 +374,8 @@ namespace AssetStudioGUI
treeNodeCollection.Add(fileNode);
}
}
treeNodeDictionary.Clear();
}
return treeNodeCollection;