public override void DeSerialize(DataReader data) { assetPath = data.ReadStringNull(); var oldOrder = data.byteOrder; data.byteOrder = DataReader.ByteOrder.Big; guidMost = data.ReadInt64(); guidLeast = data.ReadInt64(); data.byteOrder = oldOrder; type = data.ReadInt32(); filePath = data.ReadStringNull(); }
public override void DeSerialize(DataReader data) { header.DeSerialize(data); data.byteOrder = DataReader.ByteOrder.Little; UnityVersion = data.ReadStringNull(); attributes = data.ReadInt32(); numOfTypeTrees = data.ReadInt32(); typeTrees = new SerializeTypeTree[numOfTypeTrees]; for (int i = 0; i < numOfTypeTrees; i++) { typeTrees[i] = new SerializeTypeTree(); typeTrees[i].DeSerialize(data); } //padding data.ReadInt32(); numOfObjects = data.ReadInt32(); objectInfos = new SerializeAssetObject[numOfObjects]; for (int i = 0; i < numOfObjects; i++) { objectInfos[i] = new SerializeAssetObject((int)header.DataOffset); objectInfos[i].DeSerialize(data); } numOfFileIdentifiers = data.ReadInt32(); fileIdentifiers = new SerializeFileIdentifier[numOfFileIdentifiers]; for (int i = 0; i < numOfFileIdentifiers; i++) { fileIdentifiers[i] = new SerializeFileIdentifier(); fileIdentifiers[i].DeSerialize(data); } }
public override void DeSerialize(DataReader data) { name = data.ReadStringNull(); offset = data.ReadUint32(); size = data.ReadUint32(); assetData = data.GetRangeBytes(offset, size); }
public override void DeSerialize(DataReader data) { type = data.ReadStringNull(); name = data.ReadStringNull(); size = data.ReadInt32(); index = data.ReadInt32(); isArray = data.ReadInt32(); version = data.ReadInt32(); metaFlag = data.ReadInt32(); numOfChildren = data.ReadInt32(); children = new SerializeTypeTreeData[numOfChildren]; for (int i = 0; i < numOfChildren; i++) { children[i] = new SerializeTypeTreeData(); children[i].DeSerialize(data); } }
public override void DeSerialize(DataReader br) { br.byteOrder = DataReader.ByteOrder.Big; signature = br.ReadStringNull(); streamVersion = br.ReadInt32(); unityVersion = br.ReadStringNull(); unityRevision = br.ReadStringNull(); minimumStreamedBytes = br.ReadUInt32(); headerSize = br.ReadInt32(); numberOfLevelsToDownload = br.ReadInt32(); numberOfLevels = br.ReadInt32(); levelByteEnd.Clear(); for (int i = 0; i < numberOfLevels; i++) { levelByteEnd.Add(new KeyValuePair<uint, uint>(br.ReadUInt32(), br.ReadUInt32())); } completeFileSize = br.ReadUInt32(); dataHeaderSize = br.ReadUInt32(); resvers = br.ReadBytes(1); }
public override void DeSerialize(DataReader br) { br.byteOrder = DataReader.ByteOrder.Big; signature = br.ReadStringNull(); streamVersion = br.ReadInt32(); unityVersion = br.ReadStringNull(); unityRevision = br.ReadStringNull(); minimumStreamedBytes = br.ReadUInt32(); headerSize = br.ReadInt32(); numberOfLevelsToDownload = br.ReadInt32(); numberOfLevels = br.ReadInt32(); levelByteEnd.Clear(); for (int i = 0; i < numberOfLevels; i++) { levelByteEnd.Add(new KeyValuePair <uint, uint>(br.ReadUInt32(), br.ReadUInt32())); } completeFileSize = br.ReadUInt32(); dataHeaderSize = br.ReadUInt32(); resvers = br.ReadBytes(1); }
static public bool IsBundle(string path) { try { FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); DataReader data = new DataReader(fs); data.byteOrder = DataReader.ByteOrder.Big; string signature = data.ReadStringNull(); data.Close(); fs.Dispose(); if (signature.Contains("Unity")) { return true; } return false; } catch { return false; } }
static public bool IsBundle(string path) { try { FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); DataReader data = new DataReader(fs); data.byteOrder = DataReader.ByteOrder.Big; string signature = data.ReadStringNull(); data.Close(); fs.Dispose(); if (signature.Contains("Unity")) { return(true); } return(false); } catch { return(false); } }
public override void DeSerialize(DataReader br) { header.DeSerialize(br); br.byteOrder = DataReader.ByteOrder.Little; UnityVersion = br.ReadStringNull(); attributes = br.ReadInt32(); embedded = br.ReadBool(); numOfBaseClasses = br.ReadInt32(); classes = new SerializeTypeTreeData[numOfBaseClasses]; for (int i = 0; i < numOfBaseClasses; i++) { classes[i] = new SerializeTypeTreeData(embedded); classes[i].DeSerialize(br); } numOfObjects = br.ReadInt32(); objectInfos = new SerializeAssetObject[numOfObjects]; for (int i = 0; i < numOfObjects; i++) { objectInfos[i] = new SerializeAssetObject((int)header.DataOffset); objectInfos[i].DeSerialize(br); } numOfObjectIdentifiers = br.ReadInt32(); objectIdentifiers = new SerializeObjectIdentifier[numOfObjectIdentifiers]; for (int i = 0; i < numOfObjectIdentifiers; i++) { objectIdentifiers[i] = new SerializeObjectIdentifier(); objectIdentifiers[i].DeSerialize(br); } numOfFileIdentifiers = br.ReadInt32(); fileIdentifiers = new SerializeFileIdentifier[numOfFileIdentifiers]; for (int i = 0; i < numOfFileIdentifiers; i++) { fileIdentifiers[i] = new SerializeFileIdentifier(); fileIdentifiers[i].DeSerialize(br); } }
static public TypeTreeDataBase GenerateTypeTreeDataBase(SerializeAssetV15 asset) { TypeTreeDataBase DB = new TypeTreeDataBase(); Dictionary <int, string> typeNameTable = new Dictionary <int, string>(); //一个共享的类型字符串表 string defaultTypeStr = Properties.Resources.ResourceManager.GetString("TypeStringTableV15"); var typeStrArray = defaultTypeStr.Split('\n'); int startOffset = 1 << 31; for (int i = 0; i < typeStrArray.Length; i++) { typeNameTable[startOffset] = typeStrArray[i].Substring(0, typeStrArray[i].Length - 1); startOffset += typeStrArray[i].Length; } foreach (var baseClass in asset.classes) { if (baseClass.stringTable == null) { continue; } Dictionary <int, string> onwerStrTable = new Dictionary <int, string>(); MemoryStream ms = new MemoryStream(baseClass.stringTable); DataReader data = new DataReader(ms); TypeTree rootType = new TypeTree(); TypeTree nodePrev = null; Dictionary <TypeTree, int> typeLevelDic = new Dictionary <TypeTree, int>(); foreach (var field in baseClass.types) { string name = ""; string type = ""; if (field.nameOffset < 0) { if (typeNameTable.ContainsKey(field.nameOffset)) { name = typeNameTable[field.nameOffset]; } } else { data.position = field.nameOffset; name = data.ReadStringNull(); } if (field.typeOffset < 0) { if (typeNameTable.ContainsKey(field.typeOffset)) { type = typeNameTable[field.typeOffset]; } } else { data.position = field.typeOffset; type = data.ReadStringNull(); } if (nodePrev == null) { rootType.name = name; rootType.type = type; rootType.metaFlag = field.metaFlag; nodePrev = rootType; typeLevelDic[nodePrev] = field.treeLevel; continue; } TypeTree nodeCurr = new TypeTree(); nodeCurr.name = name; nodeCurr.type = type; nodeCurr.metaFlag = field.metaFlag; typeLevelDic[nodeCurr] = field.treeLevel; int levels = typeLevelDic[nodePrev] - field.treeLevel; if (levels >= 0) { for (int i = 0; i < levels; i++) { nodePrev = nodePrev.parent; } nodePrev.parent.AddChild(nodeCurr); } else { nodePrev.AddChild(nodeCurr); } nodePrev = nodeCurr; } DB.Put(15, baseClass.ClassID, rootType); Console.Write(rootType); data.Close(); ms.Close(); } return(DB); }
static public TypeTreeDataBase GenerateTypeTreeDataBase(SerializeAssetV15 asset) { TypeTreeDataBase DB = new TypeTreeDataBase(); Dictionary<int, string> typeNameTable = new Dictionary<int, string>(); //一个共享的类型字符串表 string defaultTypeStr = Properties.Resources.ResourceManager.GetString("TypeStringTableV15"); var typeStrArray = defaultTypeStr.Split('\n'); int startOffset = 1 << 31; for (int i = 0; i < typeStrArray.Length; i++) { typeNameTable[startOffset] = typeStrArray[i].Substring(0, typeStrArray[i].Length-1); startOffset += typeStrArray[i].Length; } foreach (var baseClass in asset.classes) { if (baseClass.stringTable == null) continue; Dictionary<int, string> onwerStrTable = new Dictionary<int, string>(); MemoryStream ms = new MemoryStream(baseClass.stringTable); DataReader data = new DataReader(ms); TypeTree rootType = new TypeTree(); TypeTree nodePrev = null; Dictionary<TypeTree, int> typeLevelDic = new Dictionary<TypeTree, int>(); foreach (var field in baseClass.types) { string name = ""; string type = ""; if (field.nameOffset < 0) { if (typeNameTable.ContainsKey(field.nameOffset)) { name = typeNameTable[field.nameOffset]; } } else { data.position = field.nameOffset; name = data.ReadStringNull(); } if (field.typeOffset < 0) { if (typeNameTable.ContainsKey(field.typeOffset)) { type = typeNameTable[field.typeOffset]; } } else { data.position = field.typeOffset; type = data.ReadStringNull(); } if (nodePrev == null) { rootType.name = name; rootType.type = type; rootType.metaFlag = field.metaFlag; nodePrev = rootType; typeLevelDic[nodePrev] = field.treeLevel; continue; } TypeTree nodeCurr = new TypeTree(); nodeCurr.name = name; nodeCurr.type = type; nodeCurr.metaFlag = field.metaFlag; typeLevelDic[nodeCurr] = field.treeLevel; int levels = typeLevelDic[nodePrev] - field.treeLevel; if (levels >= 0) { for (int i = 0; i < levels; i++) { nodePrev = nodePrev.parent; } nodePrev.parent.AddChild(nodeCurr); } else { nodePrev.AddChild(nodeCurr); } nodePrev = nodeCurr; } DB.Put(15, baseClass.ClassID, rootType); Console.Write(rootType); data.Close(); ms.Close(); } return DB; }