diff --git a/AssetTools.NET/Extra/MonoDeserializer/MonoDeserializer.cs b/AssetTools.NET/Extra/MonoDeserializer/MonoDeserializer.cs index 78fbe6d..4615a83 100644 --- a/AssetTools.NET/Extra/MonoDeserializer/MonoDeserializer.cs +++ b/AssetTools.NET/Extra/MonoDeserializer/MonoDeserializer.cs @@ -21,17 +21,16 @@ public class MonoClass public uint childrenCount; public AssetTypeTemplateField[] children; private AssemblyDefinition assembly; - public bool Read(string typeName, string assemblyLocation, uint format) + public bool Read(string typeName, string scriptNamespace, string assemblyLocation, uint format) { this.format = format; DefaultAssemblyResolver resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(assemblyLocation)); - ReaderParameters readerParameters = new ReaderParameters(); - readerParameters.AssemblyResolver = resolver; + ReaderParameters readerParameters = new ReaderParameters {AssemblyResolver = resolver}; assembly = AssemblyDefinition.ReadAssembly(assemblyLocation, readerParameters); children = new AssetTypeTemplateField[] { }; - children = RecursiveTypeLoad(assembly.MainModule, typeName, children); + children = RecursiveTypeLoad(assembly.MainModule, typeName, scriptNamespace, children); childrenCount = (uint)children.Length; return true; } @@ -45,12 +44,13 @@ public static AssetTypeValueField GetMonoBaseField(AssetsManager am, AssetsFileI { AssetTypeInstance scriptAti = am.GetExtAsset(inst, mainAti.GetBaseField().Get("m_Script")).instance; string scriptName = scriptAti.GetBaseField().Get("m_Name").GetValue().AsString(); + string scriptNamespace = scriptAti.GetBaseField().Get("m_Namespace").GetValue().AsString(); string assemblyName = scriptAti.GetBaseField().Get("m_AssemblyName").GetValue().AsString(); string assemblyPath = Path.Combine(managedPath, assemblyName); if (File.Exists(assemblyPath)) { MonoClass mc = new MonoClass(); - mc.Read(scriptName, assemblyPath, inst.file.header.format); + mc.Read(scriptName, scriptNamespace, assemblyPath, inst.file.header.format); AssetTypeTemplateField[] monoTemplateFields = mc.children; AssetTypeTemplateField[] templateField = baseField.children.Concat(monoTemplateFields).ToArray(); @@ -62,10 +62,10 @@ public static AssetTypeValueField GetMonoBaseField(AssetsManager am, AssetsFileI } return mainAti.GetBaseField(); } - private AssetTypeTemplateField[] RecursiveTypeLoad(ModuleDefinition module, string typeName, AssetTypeTemplateField[] attf) + private AssetTypeTemplateField[] RecursiveTypeLoad(ModuleDefinition module, string typeName, string typeNamespace, AssetTypeTemplateField[] attf) { TypeDefinition type = module.GetTypes() - .Where(t => t.Name.Equals(typeName)) + .Where(t => (t.Name.Equals(typeName) && t.Namespace.Equals(typeNamespace))) .Select(t => t) .First(); @@ -73,6 +73,7 @@ private AssetTypeTemplateField[] RecursiveTypeLoad(ModuleDefinition module, stri } private AssetTypeTemplateField[] RecursiveTypeLoad(ModuleDefinition module, TypeDefinition type, AssetTypeTemplateField[] attf) { + if (type.BaseType.Name != "Object" && type.BaseType.Name != "MonoBehaviour" && type.BaseType.Name != "ScriptableObject") @@ -278,7 +279,7 @@ private AssetTypeTemplateField SetArray(AssetTypeTemplateField field, TypeDefini size.children = new AssetTypeTemplateField[] { }; AssetTypeTemplateField data = new AssetTypeTemplateField(); - data.name = string.Copy(field.name); + data.name = "data"; data.type = string.Copy(field.type); data.valueType = field.valueType; data.isArray = false; @@ -288,7 +289,7 @@ private AssetTypeTemplateField SetArray(AssetTypeTemplateField field, TypeDefini data.children = field.children; AssetTypeTemplateField array = new AssetTypeTemplateField(); - array.name = string.Copy(field.name); + array.name = "Array"; array.type = "Array"; array.valueType = EnumValueTypes.ValueType_None; array.isArray = true; @@ -298,8 +299,12 @@ private AssetTypeTemplateField SetArray(AssetTypeTemplateField field, TypeDefini array.children = new AssetTypeTemplateField[] { size, data }; + + AssetTypeTemplateField vector = CreateTemplateField(string.Copy(field.name), "vector", EnumValueTypes.ValueType_None, 1, new AssetTypeTemplateField[] { + array + }); - return array; + return vector; } private void SetString(AssetTypeTemplateField field) { diff --git a/AssetsView/AssetHelpers/AssetInfo.cs b/AssetsView/AssetHelpers/AssetInfo.cs index e82dca9..3c034b0 100644 --- a/AssetsView/AssetHelpers/AssetInfo.cs +++ b/AssetsView/AssetHelpers/AssetInfo.cs @@ -16,8 +16,10 @@ public static string GetAssetNameFast(AssetFileInfoEx afi, ClassDatabaseFile cld if (type.fields.Count == 0) { return type.name.GetString(cldb); - } - else if (type.fields[1].fieldName.GetString(cldb) == "m_Name") + } else if (type.fields.Count == 1) { + // the dreamers lay sleeping to protect the vessel + return type.name.GetString(cldb); + } else if (type.fields[1].fieldName.GetString(cldb) == "m_Name") { reader.Position = afi.absoluteFilePos; return reader.ReadCountStringInt32(); diff --git a/AssetsView/Winforms/GameObjectViewer.cs b/AssetsView/Winforms/GameObjectViewer.cs index b0aa882..4d0f12e 100644 --- a/AssetsView/Winforms/GameObjectViewer.cs +++ b/AssetsView/Winforms/GameObjectViewer.cs @@ -193,8 +193,8 @@ private void RecursiveTreeLoad(AssetTypeValueField atvf, PGProperty node, AssetF else if (evt == EnumValueTypes.ValueType_Array || evt == EnumValueTypes.ValueType_ByteArray) { - PGProperty childProps = new PGProperty("child", null, $"[size: {atvfc.childrenCount}]"); - PGProperty prop = new PGProperty(atvfc.GetName(), childProps, $"[size: {atvfc.childrenCount}]"); + PGProperty childProps = new PGProperty("child", null, $"[ype: {atvfc.GetFieldType()} size: {atvfc.childrenCount}]"); + PGProperty prop = new PGProperty(atvfc.GetName(), childProps, $"[type: {atvf.GetFieldType()} size: {atvfc.childrenCount}]"); prop.category = category; SetSelectedStateIfSelected(info, prop); node.Add(prop); @@ -204,7 +204,7 @@ private void RecursiveTreeLoad(AssetTypeValueField atvf, PGProperty node, AssetF } else { - PGProperty childProps = new PGProperty("child"); + PGProperty childProps = new PGProperty("child", "", $"[type: {atvfc.GetFieldType()}"); PGProperty prop = new PGProperty(atvfc.GetName(), childProps); prop.category = category; SetSelectedStateIfSelected(info, prop); @@ -239,7 +239,7 @@ private void RecursiveChildSearch(TreeNode node, AssetTypeValueField field) AssetsManager.AssetExternal gameObjExt = helper.GetExtAsset(inst, newInstance.GetBaseField().Get("m_GameObject")); AssetTypeInstance newAti = gameObjExt.instance; AssetTypeValueField newBaseField = newAti.GetBaseField(); - TreeNode newNode = node.Nodes.Add(newBaseField.Get("m_Name").GetValue().AsString()); + TreeNode newNode = node.Nodes.Add(newBaseField.Get("m_Name").GetValue().AsString() + " (" + newBaseField.GetFieldType() + ")"); if (!newBaseField.Get("m_IsActive").GetValue().AsBool()) newNode.ForeColor = Color.DarkRed; newNode.Tag = newBaseField; diff --git a/UABE.NET/Winforms/AssetData.cs b/UABE.NET/Winforms/AssetData.cs index f4ba9ba..a18af9a 100644 --- a/UABE.NET/Winforms/AssetData.cs +++ b/UABE.NET/Winforms/AssetData.cs @@ -82,12 +82,13 @@ private AssetTypeTemplateField[] TryDeserializeMono(AssetTypeInstance ati) { AssetTypeInstance scriptAti = am.GetExtAsset(ati.GetBaseField().Get("m_Script")).instance; string scriptName = scriptAti.GetBaseField().Get("m_Name").GetValue().AsString(); + string scriptNamespace = scriptAti.GetBaseField().Get("m_Namespace").GetValue().AsString(); string assemblyName = scriptAti.GetBaseField().Get("m_AssemblyName").GetValue().AsString(); string assemblyPath = Path.Combine(rootDir, "Managed", assemblyName); if (File.Exists(assemblyPath)) { MonoClass mc = new MonoClass(); - mc.Read(scriptName, assemblyPath, af.header.format); + mc.Read(scriptName, scriptNamespace, assemblyPath, af.header.format); return mc.children; } else