private static void GenTypeTreeCode(ArchiveStorageHeader varStorage) { var tempCalssSet = new Dictionary <string, TypeTree2Class>(); foreach (var item in varStorage.DirectoryInfo) { if (!item.IsSerializedFile()) { continue; } var tempReader = new EndianBinaryReader(item.Context); var tempSF = new SerializedFile().Parse(tempReader); var tempObjMap = tempSF.ObjectMap; foreach (var tempKvp in tempObjMap) { var tempIdx = tempKvp.Value.typeID; var tempType = tempSF.Types[tempIdx]; var tempTreeNodes = tempType.mTypeTree.Nodes; var tempClsInfos = TypeTree2Class.Convert(tempTreeNodes); foreach (var tempClsInfo in tempClsInfos) { if (tempCalssSet.TryGetValue(tempClsInfo.ClassName, out var tempCache)) { tempCache.VaildIfConflict(tempClsInfo); } else { tempCalssSet.Add(tempClsInfo.ClassName, tempClsInfo); } } } } var tempStr = string.Empty; tempStr += "using System.Collections.Generic;\n\n"; tempStr += "namespace AssetBundleBrowser.ExtractAssets\n{"; foreach (var item in tempCalssSet) { tempStr += item.Value.Serialized(); } tempStr += "\n}"; File.WriteAllText(Path.Combine(Application.dataPath, "AssetBundles-Browser/Editor/ExtractAssets/Dumper/TypetreeGenCode.cs"), tempStr); }
public static List <TypeTree2Class> Convert(TypeTreeNode varFieldCls, List <TypeTreeNode> varTreeNodes) { PPtr.IsPPtr(varFieldCls.m_Type, out var tempClsName); if (string.IsNullOrEmpty(tempClsName)) { tempClsName = varFieldCls.m_Type; } var tempTreeClses = new List <TypeTree2Class>(); var tempAlignFields = new HashSet <string>(); var tempFieldNames = new Dictionary <string, string>(); for (int iT = varFieldCls.m_Index + 1; iT < varTreeNodes.Count; ++iT) { var tempNode = varTreeNodes[iT]; if (tempNode.m_Level <= varFieldCls.m_Level) { break; } if (tempNode.m_Level != varFieldCls.m_Level + 1) { continue; } var tempFieldName = CorrectFieldName(tempNode.m_Name); if ((tempNode.m_MetaFlag & (int)TypeTreeNode.TransferMetaFlags.kAlignBytesFlag) != 0) { tempAlignFields.Add(tempFieldName); } tempFieldNames.Add(tempFieldName, tempNode.GetNodeCsharpTypeDes(varTreeNodes, out var tempFieldTypes)); foreach (var item in tempFieldTypes) { if (!item.IsVauleType()) { tempTreeClses.AddRange(TypeTree2Class.Convert(item, varTreeNodes)); } } } tempTreeClses.Add(new TypeTree2Class(tempClsName, tempFieldNames, tempAlignFields)); return(tempTreeClses); }