public static AssetTypeValueField GetMonoBaseField(AssetsManager am, AssetsFileInstance inst, AssetFileInfoEx info, string managedPath) { AssetsFile file = inst.file; AssetTypeTemplateField baseField = new AssetTypeTemplateField(); baseField.FromClassDatabase(am.classFile, AssetHelper.FindAssetClassByID(am.classFile, info.curFileType), 0); AssetTypeInstance mainAti = new AssetTypeInstance(baseField, file.reader, false, info.absoluteFilePos); if (file.typeTree.pTypes_Unity5[info.curFileTypeOrIndex].scriptIndex != 0xFFFF) { AssetTypeInstance scriptAti = am.GetExtAsset(inst, mainAti.GetBaseField().Get("m_Script")).instance; string scriptName = scriptAti.GetBaseField().Get("m_Name").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); AssetTypeTemplateField[] monoTemplateFields = mc.children; AssetTypeTemplateField[] templateField = baseField.children.Concat(monoTemplateFields).ToArray(); baseField.children = templateField; baseField.childrenCount = (uint)baseField.children.Length; mainAti = new AssetTypeInstance(baseField, file.reader, false, info.absoluteFilePos); } } return(mainAti.GetBaseField()); }
public AssetsFileInstance GetDependency(AssetsManager am, int depIdx) { if (dependencies[depIdx] == null) { string depPath = file.dependencies.dependencies[depIdx].assetPath; int instIndex = am.files.FindIndex(f => Path.GetFileName(f.path).ToLower() == Path.GetFileName(depPath).ToLower()); if (instIndex == -1) { string pathDir = Path.GetDirectoryName(path); string absPath = Path.Combine(pathDir, depPath); string localAbsPath = Path.Combine(pathDir, Path.GetFileName(depPath)); if (File.Exists(absPath)) { dependencies[depIdx] = am.LoadAssetsFile(File.OpenRead(absPath), true); } else if (File.Exists(localAbsPath)) { dependencies[depIdx] = am.LoadAssetsFile(File.OpenRead(localAbsPath), true); } else if (parentBundle != null) { dependencies[depIdx] = am.LoadAssetsFileFromBundle(parentBundle, depPath, true); } else { return(null); } } else { dependencies[depIdx] = am.files[instIndex]; } } return(dependencies[depIdx]); }
public static AssetTypeValueField GetMonoBaseField(AssetsManager am, AssetsFileInstance inst, AssetFileInfoEx info, string managedPath, bool cached = true) { AssetsFile file = inst.file; AssetTypeTemplateField baseField = new AssetTypeTemplateField(); baseField.FromClassDatabase(am.classFile, AssetHelper.FindAssetClassByID(am.classFile, info.curFileType), 0); AssetTypeInstance mainAti = new AssetTypeInstance(baseField, file.reader, info.absoluteFilePos); ushort scriptIndex = AssetHelper.GetScriptIndex(file, info); if (scriptIndex != 0xFFFF) { AssetTypeInstance scriptAti = am.GetExtAsset(inst, mainAti.GetBaseField().Get("m_Script")).instance; string scriptName = scriptAti.GetBaseField().Get("m_ClassName").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 (scriptNamespace != string.Empty) { scriptName = scriptNamespace + "." + scriptName; } if (File.Exists(assemblyPath)) { AssemblyDefinition asmDef; if (cached) { if (!loadedAssemblies.ContainsKey(assemblyName)) { loadedAssemblies.Add(assemblyName, GetAssemblyWithDependencies(assemblyPath)); } asmDef = loadedAssemblies[assemblyName]; } else { asmDef = GetAssemblyWithDependencies(assemblyPath); } MonoDeserializer mc = new MonoDeserializer(); mc.Read(scriptName, asmDef, inst.file.header.format); List <AssetTypeTemplateField> monoTemplateFields = mc.children; AssetTypeTemplateField[] templateField = baseField.children.Concat(monoTemplateFields).ToArray(); baseField.children = templateField; baseField.childrenCount = baseField.children.Length; mainAti = new AssetTypeInstance(baseField, file.reader, info.absoluteFilePos); } } return(mainAti.GetBaseField()); }
public LambdaAssetReplacer(AssetsManager manager, AssetsFile assetsFile, AssetFileInfoEx asset, Action <AssetTypeValueField> modify) : base(manager, assetsFile, asset) { this.modify = modify; }
public LambdaAssetReplacer(AssetsManager manager, AssetsFileInstance assetsFile, AssetFileInfoEx asset, Action <AssetTypeValueField> modify) : this(manager, assetsFile.file, asset, modify) { }
protected SerializingAssetReplacer(AssetsManager manager, AssetsFile assetsFile, AssetFileInfoEx asset) { this.manager = manager; this.assetsFile = assetsFile; this.asset = asset; }
protected SerializingAssetReplacer(AssetsManager manager, AssetsFileInstance assetsFile, AssetFileInfoEx asset) : this(manager, assetsFile.file, asset) { }