public AssetTypeValueField GetMonoBaseField(AssetContainer cont, string managedPath) { var file = cont.FileInstance.file; var item = cont.Item; var baseTemp = new AssetTypeTemplateField(); baseTemp.FromClassDatabase(Am.classFile, AssetHelper.FindAssetClassByID(Am.classFile, item.TypeID), 0); var mainAti = new AssetTypeInstance(baseTemp, cont.FileReader, item.Position); var scriptIndex = item.MonoID; if (scriptIndex != 0xFFFF) { var monoScriptCont = GetAssetContainer(mainAti.GetBaseField().Get("m_Script")); if (monoScriptCont == null) { return(null); } var scriptBaseField = monoScriptCont.TypeInstance.GetBaseField(); var scriptName = scriptBaseField.Get("m_Name").GetValue().AsString(); var scriptNamespace = scriptBaseField.Get("m_Namespace").GetValue().AsString(); var assemblyName = scriptBaseField.Get("m_AssemblyName").GetValue().AsString(); var assemblyPath = Path.Combine(managedPath, assemblyName); if (scriptNamespace != string.Empty) { scriptName = scriptNamespace + "." + scriptName; } if (File.Exists(assemblyPath)) { if (!LoadedAssemblies.ContainsKey(assemblyName)) { LoadedAssemblies.Add(assemblyName, MonoDeserializer.GetAssemblyWithDependencies(assemblyPath)); } var asmDef = LoadedAssemblies[assemblyName]; var mc = new MonoDeserializer(); mc.Read(scriptName, asmDef, file.header.format); var monoTemplateFields = mc.children; var templateField = baseTemp.children.Concat(monoTemplateFields).ToArray(); baseTemp.children = templateField; baseTemp.childrenCount = baseTemp.children.Length; mainAti = new AssetTypeInstance(baseTemp, cont.FileReader, item.Position); } } return(mainAti.GetBaseField()); }
public AssetTypeValueField GetConcatMonoBaseField(AssetContainer cont, string managedPath) { AssetsFile file = cont.FileInstance.file; AssetTypeTemplateField baseTemp = new AssetTypeTemplateField(); baseTemp.FromClassDatabase(am.classFile, AssetHelper.FindAssetClassByID(am.classFile, cont.ClassId), 0); AssetTypeInstance mainAti = new AssetTypeInstance(baseTemp, cont.FileReader, cont.FilePosition); ushort scriptIndex = cont.MonoId; if (scriptIndex != 0xFFFF) { AssetContainer monoScriptCont = GetAssetContainer(cont.FileInstance, mainAti.GetBaseField().Get("m_Script"), false); if (monoScriptCont == null) return null; AssetTypeValueField scriptBaseField = monoScriptCont.TypeInstance.GetBaseField(); string scriptName = scriptBaseField.Get("m_Name").GetValue().AsString(); string scriptNamespace = scriptBaseField.Get("m_Namespace").GetValue().AsString(); string assemblyName = scriptBaseField.Get("m_AssemblyName").GetValue().AsString(); string assemblyPath = Path.Combine(managedPath, assemblyName); if (scriptNamespace != string.Empty) scriptName = scriptNamespace + "." + scriptName; if (File.Exists(assemblyPath)) { AssemblyDefinition asmDef; if (!LoadedAssemblies.ContainsKey(assemblyName)) { LoadedAssemblies.Add(assemblyName, MonoDeserializer.GetAssemblyWithDependencies(assemblyPath)); } asmDef = LoadedAssemblies[assemblyName]; MonoDeserializer mc = new MonoDeserializer(); mc.Read(scriptName, asmDef, file.header.format); List<AssetTypeTemplateField> monoTemplateFields = mc.children; AssetTypeTemplateField[] templateField = baseTemp.children.Concat(monoTemplateFields).ToArray(); baseTemp.children = templateField; baseTemp.childrenCount = baseTemp.children.Length; mainAti = new AssetTypeInstance(baseTemp, cont.FileReader, cont.FilePosition); } } return mainAti.GetBaseField(); }
public List <AssetInfo> LoadAllFSMsFromFile(string path) { curFile = am.LoadAssetsFile(path, true); am.UpdateDependencies(); am.LoadClassDatabaseFromPackage(curFile.file.typeTree.unityVersion); AssetsFile file = curFile.file; AssetsFileTable table = curFile.table; //we read manually with binaryreader to speed up reading, but sometimes the dataVersion field won't exist //so here we read the template manually to see whether it exists and back up a bit if it doesn't string assemblyPath = Path.Combine(Path.GetDirectoryName(curFile.path), "Managed", "PlayMaker.dll"); MonoDeserializer deserializer = new MonoDeserializer(); deserializer.Read("PlayMakerFSM", MonoDeserializer.GetAssemblyWithDependencies(assemblyPath), file.header.format); bool hasDataField = deserializer.children[0].children[0].name == "dataVersion"; return(GetFSMInfos(file, table, hasDataField)); }