public void Load(AssetReader input) { input.ReadInt32(); // header_size input.ReadUInt32(); // file_size m_format = input.ReadInt32(); m_data_offset = input.ReadUInt32(); if (m_format >= 9) { m_is_little_endian = 0 == input.ReadInt32(); } if (m_format >= 22) { input.ReadInt32(); // header_size input.ReadInt64(); // file_size m_data_offset = input.ReadInt64(); input.ReadInt64(); } input.SetupReaders(this); m_tree.Load(input); bool long_ids = Format >= 14; if (Format >= 7 && Format < 14) { long_ids = 0 != input.ReadInt32(); } input.SetupReadId(long_ids); int obj_count = input.ReadInt32(); for (int i = 0; i < obj_count; ++i) { input.Align(); var obj = new UnityObject(this); obj.Load(input); RegisterObject(obj); } if (Format >= 11) { int count = input.ReadInt32(); m_adds = new Dictionary <long, int> (count); for (int i = 0; i < count; ++i) { input.Align(); var id = input.ReadId(); m_adds[id] = input.ReadInt32(); } } if (Format >= 6) { int count = input.ReadInt32(); m_refs = new List <AssetRef> (count); for (int i = 0; i < count; ++i) { var asset_ref = AssetRef.Load(input); m_refs.Add(asset_ref); } } input.ReadCString(); }
public void Load(AssetReader reader, string version) { if (version != "2017.3.1f1") { Load(reader); if (0 == m_DataLength && version.StartsWith("2017.")) // "2017.2.0f3" || "2017.1.1p1" { reader.ReadInt64(); } return; } m_Name = reader.ReadString(); reader.Align(); reader.ReadInt32(); // m_ForcedFallbackFormat reader.ReadInt32(); // m_DownscaleFallback m_Width = reader.ReadInt32(); m_Height = reader.ReadInt32(); m_CompleteImageSize = reader.ReadInt32(); m_TextureFormat = (TextureFormat)reader.ReadInt32(); m_MipCount = reader.ReadInt32(); m_IsReadable = reader.ReadBool(); reader.Align(); m_ImageCount = reader.ReadInt32(); m_TextureDimension = reader.ReadInt32(); m_FilterMode = reader.ReadInt32(); m_Aniso = reader.ReadInt32(); m_MipBias = reader.ReadFloat(); m_WrapMode = reader.ReadInt32(); // m_WrapU reader.ReadInt32(); // m_WrapV reader.ReadInt32(); // m_WrapW reader.ReadInt32(); // m_LightmapFormat m_ColorSpace = reader.ReadInt32(); m_DataLength = reader.ReadInt32(); }
public void Load(AssetReader reader) { m_Name = reader.ReadString(); reader.Align(); m_LoadType = reader.ReadInt32(); m_Channels = reader.ReadInt32(); m_Frequency = reader.ReadInt32(); m_BitsPerSample = reader.ReadInt32(); m_Length = reader.ReadFloat(); m_IsTrackerFormat = reader.ReadBool(); reader.Align(); m_SubsoundIndex = reader.ReadInt32(); m_PreloadAudioData = reader.ReadBool(); m_LoadInBackground = reader.ReadBool(); m_Legacy3D = reader.ReadBool(); reader.Align(); m_Source = reader.ReadString(); reader.Align(); m_Offset = reader.ReadInt64(); m_Size = reader.ReadInt64(); m_CompressionFormat = reader.ReadInt32(); }
public void Load(AssetReader reader, UnityTypeData type) { if ("2021.1.3f1" == type.Version) // type.Hashes[28] == [0D 08 41 4C FD 5B DB 0D 22 79 20 11 BD A9 AB 26] { Load2021(reader); return; } if (type.Version != "2017.3.1f1") { Load(reader); if (0 == m_DataLength && type.Version.StartsWith("2017.")) // "2017.2.0f3" || "2017.1.1p1" { reader.ReadInt64(); } return; } m_Name = reader.ReadString(); reader.Align(); reader.ReadInt32(); // m_ForcedFallbackFormat reader.ReadInt32(); // m_DownscaleFallback m_Width = reader.ReadInt32(); m_Height = reader.ReadInt32(); m_CompleteImageSize = reader.ReadInt32(); m_TextureFormat = (TextureFormat)reader.ReadInt32(); m_MipCount = reader.ReadInt32(); m_IsReadable = reader.ReadBool(); reader.Align(); m_ImageCount = reader.ReadInt32(); m_TextureDimension = reader.ReadInt32(); m_FilterMode = reader.ReadInt32(); m_Aniso = reader.ReadInt32(); m_MipBias = reader.ReadFloat(); m_WrapMode = reader.ReadInt32(); // m_WrapU reader.ReadInt32(); // m_WrapV reader.ReadInt32(); // m_WrapW reader.ReadInt32(); // m_LightmapFormat m_ColorSpace = reader.ReadInt32(); m_DataLength = reader.ReadInt32(); }
public List <Entry> Parse(AssetReader input) { var asset = new Asset(); asset.Load(input); var dir = new List <Entry>(); m_bundles = new Dictionary <string, BundleEntry>(); var used_names = new HashSet <string>(); foreach (var obj in asset.Objects.Where(o => o.TypeId > 0)) { input.Position = obj.Offset; AssetEntry entry = null; switch (obj.TypeId) { default: break; case 28: // Texture2D { var tex = new Texture2D(); tex.Load(input); if (0 == tex.m_DataLength) { if (asset.Tree.Version.StartsWith("2017.")) // "2017.2.0f3" || "2017.1.1p1" { input.ReadInt64(); } var stream_data = new StreamingInfo(); stream_data.Load(input); if (!string.IsNullOrEmpty(stream_data.Path)) { entry = new AssetEntry { Name = tex.m_Name, Type = "image", Offset = stream_data.Offset, Size = stream_data.Size, Bundle = GetBundle(stream_data.Path), }; } } else { entry = new AssetEntry { Name = tex.m_Name, Type = "image", Offset = obj.Offset, Size = obj.Size, }; } break; } case 83: // AudioClip { var clip = new AudioClip(); clip.Load(input); if (!string.IsNullOrEmpty(clip.m_Source)) { entry = new AssetEntry { Name = clip.m_Name, Type = "audio", Offset = clip.m_Offset, Size = (uint)clip.m_Size, Bundle = GetBundle(clip.m_Source), }; } break; } case 49: // TextAsset { var name = input.ReadString(); input.Align(); uint size = input.ReadUInt32(); entry = new AssetEntry { Name = name, Offset = input.Position, Size = size, }; if (name.HasAnyOfExtensions("jpg", "png")) { entry.Type = "image"; } break; } case 128: // Font { entry = new AssetEntry { Offset = obj.Offset, Size = obj.Size, }; break; } } if (entry != null) { entry.AssetObject = obj; if (string.IsNullOrEmpty(entry.Name)) { entry.Name = string.Format("{0:D4} [{1}]", obj.PathId, obj.TypeId); } else if (!used_names.Add(entry.Name)) { entry.Name = string.Format("{0}-{1}", entry.Name, obj.PathId); } dir.Add(entry); } } return(dir); }