public Shader(ObjectReader reader) : base(reader) { if (version[0] == 5 && version[1] >= 5 || version[0] > 5) //5.5 and up { m_ParsedForm = new SerializedShader(reader); platforms = reader.ReadUInt32Array().Select(x => (ShaderCompilerPlatform)x).ToArray(); if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up { offsets = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray(); compressedLengths = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray(); decompressedLengths = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray(); } else { offsets = reader.ReadUInt32Array(); compressedLengths = reader.ReadUInt32Array(); decompressedLengths = reader.ReadUInt32Array(); } compressedBlob = reader.ReadBytes(reader.ReadInt32()); } else { m_Script = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(); var m_PathName = reader.ReadAlignedString(); if (version[0] == 5 && version[1] >= 3) //5.3 - 5.4 { decompressedSize = reader.ReadUInt32(); m_SubProgramBlob = reader.ReadBytes(reader.ReadInt32()); } } }
public Shader(ObjectReader reader) : base(reader) { if (version[0] == 5 && version[1] >= 5 || version[0] > 5) //5.5.0 and up { var str = reader.Dump(); m_Script = Encoding.UTF8.GetBytes(str ?? "Serialized Shader can't be read"); } else { m_Script = reader.ReadBytes(reader.ReadInt32()); if (version[0] == 5 && version[1] >= 3) //5.3 - 5.4 { reader.AlignStream(4); var m_PathName = reader.ReadAlignedString(); var decompressedSize = reader.ReadUInt32(); var m_SubProgramBlob = reader.ReadBytes(reader.ReadInt32()); var decompressedBytes = new byte[decompressedSize]; using (var decoder = new Lz4DecoderStream(new MemoryStream(m_SubProgramBlob))) { decoder.Read(decompressedBytes, 0, (int)decompressedSize); } m_Script = m_Script.Concat(decompressedBytes.ToArray()).ToArray(); } } }
public MonoScript(ObjectReader reader) : base(reader) { if (version[0] > 3 || (version[0] == 3 && version[1] >= 4)) //3.4 and up { var m_ExecutionOrder = reader.ReadInt32(); } if (version[0] < 5) //5.0 down { var m_PropertiesHash = reader.ReadUInt32(); } else { var m_PropertiesHash = reader.ReadBytes(16); } if (version[0] < 3) //3.0 down { var m_PathName = reader.ReadAlignedString(); } m_ClassName = reader.ReadAlignedString(); if (version[0] >= 3) //3.0 and up { m_Namespace = reader.ReadAlignedString(); } m_AssemblyName = reader.ReadAlignedString(); if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down { var m_IsEditorScript = reader.ReadBoolean(); } }
public SpriteAtlas(ObjectReader reader) : base(reader) { var m_PackedSpritesSize = reader.ReadInt32(); for (int i = 0; i < m_PackedSpritesSize; i++) { reader.ReadPPtr(); //PPtr<Sprite> data } var m_PackedSpriteNamesToIndexSize = reader.ReadInt32(); for (int i = 0; i < m_PackedSpriteNamesToIndexSize; i++) { reader.ReadAlignedString(); } var m_RenderDataMapSize = reader.ReadInt32(); m_RenderDataMap = new Dictionary <Tuple <Guid, long>, SpriteAtlasData>(m_RenderDataMapSize); for (int i = 0; i < m_RenderDataMapSize; i++) { var first = new Guid(reader.ReadBytes(16)); var second = reader.ReadInt64(); var value = new SpriteAtlasData(reader); m_RenderDataMap.Add(new Tuple <Guid, long>(first, second), value); } //string m_Tag //bool m_IsVariant }
public SpriteAtlas(ObjectReader reader) : base(reader) { var m_PackedSpritesSize = reader.ReadInt32(); m_PackedSprites = new PPtr <Sprite> [m_PackedSpritesSize]; for (int i = 0; i < m_PackedSpritesSize; i++) { m_PackedSprites[i] = new PPtr <Sprite>(reader); } var m_PackedSpriteNamesToIndex = reader.ReadStringArray(); var m_RenderDataMapSize = reader.ReadInt32(); m_RenderDataMap = new Dictionary <KeyValuePair <Guid, long>, SpriteAtlasData>(m_RenderDataMapSize); for (int i = 0; i < m_RenderDataMapSize; i++) { var first = new Guid(reader.ReadBytes(16)); var second = reader.ReadInt64(); var value = new SpriteAtlasData(reader); m_RenderDataMap.Add(new KeyValuePair <Guid, long>(first, second), value); } //string m_Tag //bool m_IsVariant }
public Shader(ObjectReader reader) : base(reader) { if (version[0] == 5 && version[1] >= 5 || version[0] > 5) //5.5 and up { m_ParsedForm = new SerializedShader(reader); int numPlatforms = reader.ReadInt32(); platforms = new List <uint>(numPlatforms); for (int i = 0; i < numPlatforms; i++) { platforms.Add(reader.ReadUInt32()); } int numOffsets = reader.ReadInt32(); offsets = new List <uint>(numOffsets); for (int i = 0; i < numOffsets; i++) { offsets.Add(reader.ReadUInt32()); } int numCompressedLengths = reader.ReadInt32(); compressedLengths = new List <uint>(numCompressedLengths); for (int i = 0; i < numCompressedLengths; i++) { compressedLengths.Add(reader.ReadUInt32()); } int numDecompressedLengths = reader.ReadInt32(); decompressedLengths = new List <uint>(numDecompressedLengths); for (int i = 0; i < numDecompressedLengths; i++) { decompressedLengths.Add(reader.ReadUInt32()); } compressedBlob = reader.ReadBytes(reader.ReadInt32()); } else { m_Script = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(4); var m_PathName = reader.ReadAlignedString(); if (version[0] == 5 && version[1] >= 3) //5.3 - 5.4 { decompressedSize = reader.ReadUInt32(); m_SubProgramBlob = reader.ReadBytes(reader.ReadInt32()); } } }
public MovieTexture(ObjectReader reader) : base(reader) { var m_Loop = reader.ReadBoolean(); reader.AlignStream(4); m_AudioClip = new PPtr <AudioClip>(reader); m_MovieData = reader.ReadBytes(reader.ReadInt32()); }
public PackedQuatVector(ObjectReader reader) { m_NumItems = reader.ReadUInt32(); int numData = reader.ReadInt32(); m_Data = reader.ReadBytes(numData); reader.AlignStream(4); }
public Sprite(ObjectReader reader) : base(reader) { m_Rect = reader.ReadRectangleF(); m_Offset = reader.ReadVector2(); if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up { m_Border = reader.ReadVector4(); } m_PixelsToUnits = reader.ReadSingle(); if (version[0] > 5 || (version[0] == 5 && version[1] > 4) || (version[0] == 5 && version[1] == 4 && version[2] >= 2)) //5.4.2 and up { m_Pivot = reader.ReadVector2(); } m_Extrude = reader.ReadUInt32(); if (version[0] > 5 || (version[0] == 5 && version[1] >= 3)) //5.3 and up { m_IsPolygon = reader.ReadBoolean(); reader.AlignStream(4); } if (version[0] >= 2017) //2017 and up { var first = new Guid(reader.ReadBytes(16)); var second = reader.ReadInt64(); m_RenderDataKey = new KeyValuePair <Guid, long>(first, second); var m_AtlasTagsSize = reader.ReadInt32(); m_AtlasTags = new string[m_AtlasTagsSize]; for (int i = 0; i < m_AtlasTagsSize; i++) { m_AtlasTags[i] = reader.ReadAlignedString(); } m_SpriteAtlas = new PPtr <SpriteAtlas>(reader); } m_RD = new SpriteRenderData(reader); if (version[0] >= 2017) //2017 and up { var m_PhysicsShapeSize = reader.ReadInt32(); m_PhysicsShape = new Vector2[m_PhysicsShapeSize][]; for (int i = 0; i < m_PhysicsShapeSize; i++) { m_PhysicsShape[i] = reader.ReadVector2Array(reader.ReadInt32()); } } //vector m_Bones 2018 and up }
public PackedIntVector(ObjectReader reader) { m_NumItems = reader.ReadUInt32(); var numData = reader.ReadInt32(); m_Data = reader.ReadBytes(numData); reader.AlignStream(); m_BitSize = reader.ReadByte(); reader.AlignStream(); }
public VideoClip(ObjectReader reader, bool readData) : base(reader) { m_OriginalPath = reader.ReadAlignedString(); var m_ProxyWidth = reader.ReadUInt32(); var m_ProxyHeight = reader.ReadUInt32(); var Width = reader.ReadUInt32(); var Height = reader.ReadUInt32(); if (version[0] >= 2017)//2017.x and up { var m_PixelAspecRatioNum = reader.ReadUInt32(); var m_PixelAspecRatioDen = reader.ReadUInt32(); } var m_FrameRate = reader.ReadDouble(); var m_FrameCount = reader.ReadUInt64(); var m_Format = reader.ReadInt32(); //m_AudioChannelCount var size = reader.ReadInt32(); reader.Position += size * 2; reader.AlignStream(4); //m_AudioSampleRate size = reader.ReadInt32(); reader.Position += size * 4; //m_AudioLanguage size = reader.ReadInt32(); for (int i = 0; i < size; i++) { reader.ReadAlignedString(); } //StreamedResource m_ExternalResources m_Source = reader.ReadAlignedString(); var m_Offset = reader.ReadUInt64(); m_Size = reader.ReadUInt64(); var m_HasSplitAlpha = reader.ReadBoolean(); if (readData) { if (!string.IsNullOrEmpty(m_Source)) { m_VideoData = ResourcesHelper.GetData(m_Source, sourceFile, (long)m_Offset, (int)m_Size); } else { if (m_Size > 0) { m_VideoData = reader.ReadBytes((int)m_Size); } } } }
public VertexData(ObjectReader reader) { var version = reader.version; if (version[0] < 2018)//2018 down { m_CurrentChannels = reader.ReadUInt32(); } m_VertexCount = reader.ReadUInt32(); if (version[0] >= 4) //4.0 and up { var m_ChannelsSize = reader.ReadInt32(); m_Channels = new ChannelInfo[m_ChannelsSize]; for (int i = 0; i < m_ChannelsSize; i++) { m_Channels[i] = new ChannelInfo(reader); } } if (version[0] < 5) //5.0 down { if (version[0] < 4) { m_Streams = new StreamInfo[4]; } else { m_Streams = new StreamInfo[reader.ReadInt32()]; } for (int i = 0; i < m_Streams.Length; i++) { m_Streams[i] = new StreamInfo(reader); } if (version[0] < 4) //4.0 down { GetChannels(version); } } else //5.0 and up { GetStreams(version); } m_DataSize = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(); }
public PackedFloatVector(ObjectReader reader) { m_NumItems = reader.ReadUInt32(); m_Range = reader.ReadSingle(); m_Start = reader.ReadSingle(); int numData = reader.ReadInt32(); m_Data = reader.ReadBytes(numData); reader.AlignStream(4); m_BitSize = reader.ReadByte(); reader.AlignStream(4); }
public PlayerSettings(ObjectReader reader) : base(reader) { if (version[0] > 5 || (version[0] == 5 && version[1] >= 4)) //5.4.0 nad up { var productGUID = reader.ReadBytes(16); } var AndroidProfiler = reader.ReadBoolean(); //bool AndroidFilterTouchesWhenObscured 2017.2 and up //bool AndroidEnableSustainedPerformanceMode 2018 and up reader.AlignStream(); var defaultScreenOrientation = reader.ReadInt32(); var targetDevice = reader.ReadInt32(); if (version[0] < 5 || (version[0] == 5 && version[1] < 3)) //5.3 down { if (version[0] < 5) //5.0 down { var targetPlatform = reader.ReadInt32(); //4.0 and up targetGlesGraphics if (version[0] > 4 || (version[0] == 4 && version[1] >= 6)) //4.6 and up { var targetIOSGraphics = reader.ReadInt32(); } } var targetResolution = reader.ReadInt32(); } else { var useOnDemandResources = reader.ReadBoolean(); reader.AlignStream(); } if (version[0] > 3 || (version[0] == 3 && version[1] >= 5)) //3.5 and up { var accelerometerFrequency = reader.ReadInt32(); } companyName = reader.ReadAlignedString(); productName = reader.ReadAlignedString(); }
public PointF[][] m_PhysicsShape; //Vector2[][] public Sprite(ObjectReader reader) : base(reader) { //Rectf m_Rect m_Rect = reader.ReadRectangleF(); //Vector2f m_Offset reader.Position += 8; if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up { //Vector4f m_Border reader.Position += 16; } m_PixelsToUnits = reader.ReadSingle(); if (version[0] > 5 || (version[0] == 5 && version[1] > 4) || (version[0] == 5 && version[1] == 4 && version[2] >= 2)) //5.4.2 and up { //Vector2f m_Pivot m_Pivot = reader.ReadVector2(); } var m_Extrude = reader.ReadUInt32(); if (version[0] > 5 || (version[0] == 5 && version[1] >= 3)) //5.3 and up { var m_IsPolygon = reader.ReadBoolean(); reader.AlignStream(4); } if (version[0] >= 2017) //2017 and up { //pair m_RenderDataKey var first = new Guid(reader.ReadBytes(16)); var second = reader.ReadInt64(); m_RenderDataKey = new Tuple <Guid, long>(first, second); //vector m_AtlasTags var size = reader.ReadInt32(); for (int i = 0; i < size; i++) { var data = reader.ReadAlignedString(); } //PPtr<SpriteAtlas> m_SpriteAtlas m_SpriteAtlas = reader.ReadPPtr(); } //SpriteRenderData m_RD // PPtr<Texture2D> texture texture = reader.ReadPPtr(); // PPtr<Texture2D> alphaTexture if (version[0] > 5 || (version[0] == 5 && version[1] >= 2)) //5.2 and up { var alphaTexture = reader.ReadPPtr(); } if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up { // vector m_SubMeshes var size = reader.ReadInt32(); // SubMesh data if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up { reader.Position += 48 * size; } else { reader.Position += 44 * size; } // vector m_IndexBuffer size = reader.ReadInt32(); reader.Position += size; //UInt8 data reader.AlignStream(4); // VertexData m_VertexData if (version[0] < 2018)//2018 down { var m_CurrentChannels = reader.ReadInt32(); } var m_VertexCount = reader.ReadUInt32(); // vector m_Channels size = reader.ReadInt32(); reader.Position += size * 4; //ChannelInfo data // TypelessData m_DataSize size = reader.ReadInt32(); reader.Position += size; //UInt8 data reader.AlignStream(4); if (version[0] >= 2018)//2018 and up { // vector m_Bindpose // Matrix4x4f data size = reader.ReadInt32(); reader.Position += size * 64; if (version[0] == 2018 && version[1] < 2) //2018.2 down { // vector m_SourceSkin // BoneWeights4 data size = reader.ReadInt32(); reader.Position += size * 32; } } } else { // vector vertices var size = reader.ReadInt32(); for (int i = 0; i < size; i++) { //SpriteVertex data reader.Position += 12; //Vector3f pos if (version[0] < 4 || (version[0] == 4 && version[1] <= 3)) //4.3 and down { reader.Position += 8; //Vector2f uv } } // vector indices size = reader.ReadInt32(); reader.Position += 2 * size; //UInt16 data reader.AlignStream(4); } // Rectf textureRect textureRect = reader.ReadRectangleF(); // Vector2f textureRectOffset reader.Position += 8; // Vector2f atlasRectOffset - 5.6 and up if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up { reader.Position += 8; } // unsigned int settingsRaw settingsRaw = new SpriteSettings(reader); // Vector4f uvTransform - 4.5 and up if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up { reader.Position += 16; } if (version[0] >= 2017) //2017 and up { // float downscaleMultiplier - 2017 and up reader.Position += 4; //vector m_PhysicsShape - 2017 and up var m_PhysicsShape_size = reader.ReadInt32(); m_PhysicsShape = new PointF[m_PhysicsShape_size][]; for (int i = 0; i < m_PhysicsShape_size; i++) { var data_size = reader.ReadInt32(); //Vector2f m_PhysicsShape[i] = new PointF[data_size]; for (int j = 0; j < data_size; j++) { m_PhysicsShape[i][j] = new PointF(reader.ReadSingle(), reader.ReadSingle()); } } } //vector m_Bones 2018 and up }
public List <uint> m_Indices = new List <uint>(); //use a list because I don't always know the facecount for triangle strips public Mesh(ObjectReader reader) : base(reader) { if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) //3.5 down { m_Use16BitIndices = reader.ReadInt32() > 0; } if (version[0] == 2 && version[1] <= 5) //2.5 and down { int m_IndexBuffer_size = reader.ReadInt32(); if (m_Use16BitIndices) { m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = reader.ReadUInt16(); } reader.AlignStream(); } else { m_IndexBuffer = new uint[m_IndexBuffer_size / 4]; for (int i = 0; i < m_IndexBuffer_size / 4; i++) { m_IndexBuffer[i] = reader.ReadUInt32(); } } } int m_SubMeshesSize = reader.ReadInt32(); m_SubMeshes = new SubMesh[m_SubMeshesSize]; for (int i = 0; i < m_SubMeshesSize; i++) { m_SubMeshes[i] = new SubMesh(reader); } if (version[0] == 4 && ((version[1] == 1 && !buildType.IsAlpha) || (version[1] > 1 && version[1] <= 2))) //4.1.0 to 4.2.x, excluding 4.1.0 alpha { int m_Shapes_size = reader.ReadInt32(); if (m_Shapes_size > 0) { //bool stop = true; } for (int s = 0; s < m_Shapes_size; s++) //untested { var shape_name = reader.ReadAlignedString(); reader.Position += 36; //uint firstVertex, vertexCount; Vector3f aabbMinDelta, aabbMaxDelta; bool hasNormals, hasTangents } int m_ShapeVertices_size = reader.ReadInt32(); reader.Position += m_ShapeVertices_size * 40; //vertex positions, normals, tangents & uint index } else if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3.0 and later { m_Shapes = new BlendShapeData(reader); m_BindPose = reader.ReadMatrixArray(); m_BoneNameHashes = reader.ReadUInt32Array(); var m_RootBoneNameHash = reader.ReadUInt32(); } if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and later { var m_MeshCompression = reader.ReadByte(); if (version[0] >= 4) { if (version[0] < 5) { var m_StreamCompression = reader.ReadByte(); } var m_IsReadable = reader.ReadBoolean(); var m_KeepVertices = reader.ReadBoolean(); var m_KeepIndices = reader.ReadBoolean(); } reader.AlignStream(); //Unity fixed it in 2017.3.1p1 and later versions if ((version[0] > 2017 || (version[0] == 2017 && version[1] >= 4)) || //2017.4 ((version[0] == 2017 && version[1] == 3 && version[2] == 1) && buildType.IsPatch) || //fixed after 2017.3.1px ((version[0] == 2017 && version[1] == 3) && m_MeshCompression == 0)) //2017.3.xfx with no compression { var m_IndexFormat = reader.ReadInt32(); } int m_IndexBuffer_size = reader.ReadInt32(); if (m_Use16BitIndices) { m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = reader.ReadUInt16(); } reader.AlignStream(); } else { m_IndexBuffer = new uint[m_IndexBuffer_size / 4]; for (int i = 0; i < m_IndexBuffer_size / 4; i++) { m_IndexBuffer[i] = reader.ReadUInt32(); } reader.AlignStream(); } } if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) //3.4.2 and earlier { m_VertexCount = reader.ReadInt32(); m_Vertices = reader.ReadSingleArray(m_VertexCount * 3); //Vector3 m_Skin = new BoneWeights4[reader.ReadInt32()]; for (int s = 0; s < m_Skin.Length; s++) { m_Skin[s] = new BoneWeights4(reader); } m_BindPose = reader.ReadMatrixArray(); m_UV0 = reader.ReadSingleArray(reader.ReadInt32() * 2); //Vector2 m_UV1 = reader.ReadSingleArray(reader.ReadInt32() * 2); //Vector2 if (version[0] == 2 && version[1] <= 5) //2.5 and down { int m_TangentSpace_size = reader.ReadInt32(); m_Normals = new float[m_TangentSpace_size * 3]; for (int v = 0; v < m_TangentSpace_size; v++) { m_Normals[v * 3] = reader.ReadSingle(); m_Normals[v * 3 + 1] = reader.ReadSingle(); m_Normals[v * 3 + 2] = reader.ReadSingle(); reader.Position += 16; //Vector3f tangent & float handedness } } else //2.6.0 and later { m_Tangents = reader.ReadSingleArray(reader.ReadInt32() * 4); //Vector4 m_Normals = reader.ReadSingleArray(reader.ReadInt32() * 3); //Vector3 } } else { if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down { m_Skin = new BoneWeights4[reader.ReadInt32()]; for (int s = 0; s < m_Skin.Length; s++) { m_Skin[s] = new BoneWeights4(reader); } } if (version[0] == 3 || (version[0] == 4 && version[1] <= 2)) //4.2 and down { m_BindPose = reader.ReadMatrixArray(); } m_VertexData = new VertexData(reader); } if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and later { m_CompressedMesh = new CompressedMesh(reader); } reader.Position += 24; //AABB m_LocalAABB if (version[0] < 3 || (version[0] == 3 && version[1] <= 4)) //3.4.2 and earlier { int m_Colors_size = reader.ReadInt32(); m_Colors = new float[m_Colors_size * 4]; for (int v = 0; v < m_Colors_size * 4; v++) { m_Colors[v] = (float)reader.ReadByte() / 0xFF; } int m_CollisionTriangles_size = reader.ReadInt32(); reader.Position += m_CollisionTriangles_size * 4; //UInt32 indices int m_CollisionVertexCount = reader.ReadInt32(); } int m_MeshUsageFlags = reader.ReadInt32(); if (version[0] >= 5) //5.0 and up { var m_BakedConvexCollisionMesh = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(); var m_BakedTriangleCollisionMesh = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(); } if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up { var m_MeshMetrics = new float[2]; m_MeshMetrics[0] = reader.ReadSingle(); m_MeshMetrics[1] = reader.ReadSingle(); } if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 3)) //2018.3 and up { reader.AlignStream(); m_StreamData = new StreamingInfo(reader); } ProcessData(); }
public TextAsset(ObjectReader reader) : base(reader) { m_Script = reader.ReadBytes(reader.ReadInt32()); }
public SpriteRenderData(ObjectReader reader) { var version = reader.version; texture = new PPtr <Texture2D>(reader); if (version[0] > 5 || (version[0] == 5 && version[1] >= 2)) //5.2 and up { alphaTexture = new PPtr <Texture2D>(reader); } if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up { var m_SubMeshesSize = reader.ReadInt32(); m_SubMeshes = new SubMesh[m_SubMeshesSize]; for (int i = 0; i < m_SubMeshesSize; i++) { m_SubMeshes[i] = new SubMesh(reader); } m_IndexBuffer = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(4); m_VertexData = new VertexData(reader); } else { var verticesSize = reader.ReadInt32(); vertices = new SpriteVertex[verticesSize]; for (int i = 0; i < verticesSize; i++) { vertices[i] = new SpriteVertex(reader); } indices = reader.ReadUInt16Array(reader.ReadInt32()); reader.AlignStream(4); } if (version[0] >= 2018) //2018 and up { m_Bindpose = reader.ReadMatrixArray(reader.ReadInt32()); if (version[0] == 2018 && version[1] < 2) //2018.2 down { var m_SourceSkinSize = reader.ReadInt32(); for (int i = 0; i < m_SourceSkinSize; i++) { m_SourceSkin[i] = new BoneWeights4(reader); } } } textureRect = reader.ReadRectangleF(); textureRectOffset = reader.ReadVector2(); if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up { atlasRectOffset = reader.ReadVector2(); } settingsRaw = new SpriteSettings(reader); if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up { uvTransform = reader.ReadVector4(); } if (version[0] >= 2017) //2017 and up { downscaleMultiplier = reader.ReadSingle(); } }
public byte[] GetRawData() { reader.Reset(); return(reader.ReadBytes((int)byteSize)); }
protected Renderer(ObjectReader reader, bool isSkinned = false) : base(reader) { if (version[0] < 5) //5.0 down { var m_Enabled = reader.ReadBoolean(); var m_CastShadows = reader.ReadBoolean(); var m_ReceiveShadows = reader.ReadBoolean(); var m_LightmapIndex = reader.ReadByte(); } else //5.0 and up { if (version[0] > 5 || (version[0] == 5 && version[1] >= 4)) //5.4 and up { var m_Enabled = reader.ReadBoolean(); var m_CastShadows = reader.ReadByte(); var m_ReceiveShadows = reader.ReadByte(); if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up { var m_DynamicOccludee = reader.ReadByte(); } if (version[0] >= 2021) //2021.1 and up { var m_StaticShadowCaster = reader.ReadByte(); } var m_MotionVectors = reader.ReadByte(); var m_LightProbeUsage = reader.ReadByte(); var m_ReflectionProbeUsage = reader.ReadByte(); if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up { var m_RayTracingMode = reader.ReadByte(); } if (version[0] >= 2020) //2020.1 and up { var m_RayTraceProcedural = reader.ReadByte(); } reader.AlignStream(); } else { var m_Enabled = reader.ReadBoolean(); reader.AlignStream(); var m_CastShadows = reader.ReadByte(); var m_ReceiveShadows = reader.ReadBoolean(); reader.AlignStream(); } if (version[0] >= 2018) //2018 and up { var m_RenderingLayerMask = reader.ReadUInt32(); } if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 3)) //2018.3 and up { var m_RendererPriority = reader.ReadInt32(); } // ??? //var unk1 = reader.ReadBytes(isSkinned ? 0xC : 0x10); var unk1 = reader.ReadBytes(0x10); var m_LightmapIndex = reader.ReadUInt16(); var m_LightmapIndexDynamic = reader.ReadUInt16(); } if (version[0] >= 3) //3.0 and up { var m_LightmapTilingOffset = reader.ReadVector4(); } if (version[0] >= 5) //5.0 and up { var m_LightmapTilingOffsetDynamic = reader.ReadVector4(); } // ??? var unk2 = reader.ReadVector2(); var m_MaterialsSize = reader.ReadInt32(); m_Materials = new PPtr <Material> [m_MaterialsSize]; for (int i = 0; i < m_MaterialsSize; i++) { m_Materials[i] = new PPtr <Material>(reader); } if (version[0] < 3) //3.0 down { var m_LightmapTilingOffset = reader.ReadVector4(); } else //3.0 and up { if (version[0] > 5 || (version[0] == 5 && version[1] >= 5)) //5.5 and up { m_StaticBatchInfo = new StaticBatchInfo(reader); } else { m_SubsetIndices = reader.ReadUInt32Array(); } var m_StaticBatchRoot = new PPtr <Transform>(reader); } if (version[0] > 5 || (version[0] == 5 && version[1] >= 4)) //5.4 and up { var m_ProbeAnchor = new PPtr <Transform>(reader); var m_LightProbeVolumeOverride = new PPtr <GameObject>(reader); } else if (version[0] > 3 || (version[0] == 3 && version[1] >= 5)) //3.5 - 5.3 { var m_UseLightProbes = reader.ReadBoolean(); reader.AlignStream(); if (version[0] >= 5)//5.0 and up { var m_ReflectionProbeUsage = reader.ReadInt32(); } var m_LightProbeAnchor = new PPtr <Transform>(reader); //5.0 and up m_ProbeAnchor } if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up { if (version[0] == 4 && version[1] == 3) //4.3 { var m_SortingLayer = reader.ReadInt16(); } else { var m_SortingLayerID = reader.ReadUInt32(); } //SInt16 m_SortingLayer 5.6 and up var m_SortingOrder = reader.ReadInt16(); reader.AlignStream(); } }
public Texture2D(ObjectReader reader, bool readData) : base(reader) { m_Width = reader.ReadInt32(); m_Height = reader.ReadInt32(); m_CompleteImageSize = reader.ReadInt32(); m_TextureFormat = (TextureFormat)reader.ReadInt32(); if (version[0] < 5 || (version[0] == 5 && version[1] < 2)) { m_MipMap = reader.ReadBoolean(); } else { m_MipCount = reader.ReadInt32(); } m_IsReadable = reader.ReadBoolean(); //2.6.0 and up m_ReadAllowed = reader.ReadBoolean(); //3.0.0 - 5.4 //m_StreamingMipmaps 2018.2 and up reader.AlignStream(4); if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up { var m_StreamingMipmapsPriority = reader.ReadInt32(); } else if (reader.HasStructMember("m_StreamingMipmapsPriority")) //will fix in some patch version bundle { var m_StreamingMipmapsPriority = reader.ReadInt32(); } if (reader.HasStructMember("m_StreamingGroupID")) //What the hell is this? { var m_StreamingGroupID = reader.ReadUInt32(); } m_ImageCount = reader.ReadInt32(); m_TextureDimension = reader.ReadInt32(); //m_TextureSettings m_FilterMode = reader.ReadInt32(); m_Aniso = reader.ReadInt32(); m_MipBias = reader.ReadSingle(); if (version[0] >= 2017)//2017.x and up { int m_WrapU = reader.ReadInt32(); int m_WrapV = reader.ReadInt32(); int m_WrapW = reader.ReadInt32(); } else { m_WrapMode = reader.ReadInt32(); } if (version[0] >= 3) { m_LightmapFormat = reader.ReadInt32(); if (version[0] >= 4 || version[1] >= 5)//3.5.0 and up { m_ColorSpace = reader.ReadInt32(); } } image_data_size = reader.ReadInt32(); if (image_data_size == 0 && ((version[0] == 5 && version[1] >= 3) || version[0] > 5))//5.3.0 and up { offset = reader.ReadUInt32(); size = reader.ReadUInt32(); image_data_size = (int)size; path = reader.ReadAlignedString(); } if (readData) { if (!string.IsNullOrEmpty(path)) { image_data = ResourcesHelper.GetData(path, sourceFile, offset, image_data_size); } else { image_data = reader.ReadBytes(image_data_size); } } }
public AudioClip(ObjectReader reader, bool readData) : base(reader) { if (version[0] < 5) { m_Format = reader.ReadInt32(); m_Type = (AudioType)reader.ReadInt32(); m_3D = reader.ReadBoolean(); m_UseHardware = reader.ReadBoolean(); reader.AlignStream(4); if (version[0] >= 4 || (version[0] == 3 && version[1] >= 2)) //3.2.0 to 5 { int m_Stream = reader.ReadInt32(); m_Size = reader.ReadInt32(); var tsize = m_Size % 4 != 0 ? m_Size + 4 - m_Size % 4 : m_Size; if (reader.byteSize + reader.byteStart - reader.Position != tsize) { m_Offset = reader.ReadInt32(); m_Source = sourceFile.filePath + ".resS"; } } else { m_Size = reader.ReadInt32(); } } else { m_LoadType = reader.ReadInt32(); m_Channels = reader.ReadInt32(); m_Frequency = reader.ReadInt32(); m_BitsPerSample = reader.ReadInt32(); m_Length = reader.ReadSingle(); m_IsTrackerFormat = reader.ReadBoolean(); reader.AlignStream(4); m_SubsoundIndex = reader.ReadInt32(); m_PreloadAudioData = reader.ReadBoolean(); m_LoadInBackground = reader.ReadBoolean(); m_Legacy3D = reader.ReadBoolean(); reader.AlignStream(4); m_3D = m_Legacy3D; m_Source = reader.ReadAlignedString(); m_Offset = reader.ReadInt64(); m_Size = reader.ReadInt64(); m_CompressionFormat = (AudioCompressionFormat)reader.ReadInt32(); } if (readData) { if (!string.IsNullOrEmpty(m_Source)) { m_AudioData = ResourcesHelper.GetData(m_Source, sourceFile.filePath, m_Offset, (int)m_Size); } else { if (m_Size > 0) { m_AudioData = reader.ReadBytes((int)m_Size); } } } }
public Font(ObjectReader reader) : base(reader) { if ((version[0] == 5 && version[1] >= 5) || version[0] > 5)//5.5 and up { var m_LineSpacing = reader.ReadSingle(); var m_DefaultMaterial = new PPtr <Material>(reader); var m_FontSize = reader.ReadSingle(); var m_Texture = new PPtr <Texture>(reader); var m_AsciiStartOffset = reader.ReadInt32(); var m_Tracking = reader.ReadSingle(); var m_CharacterSpacing = reader.ReadInt32(); var m_CharacterPadding = reader.ReadInt32(); var m_ConvertCase = reader.ReadInt32(); var m_CharacterRects_size = reader.ReadInt32(); for (var i = 0; i < m_CharacterRects_size; i++) { reader.Position += 44;//CharacterInfo data 41 } var m_KerningValues_size = reader.ReadInt32(); for (var i = 0; i < m_KerningValues_size; i++) { reader.Position += 8; } var m_PixelScale = reader.ReadSingle(); var m_FontData_size = reader.ReadInt32(); if (m_FontData_size > 0) { m_FontData = reader.ReadBytes(m_FontData_size); } } else { var m_AsciiStartOffset = reader.ReadInt32(); if (version[0] <= 3) { var m_FontCountX = reader.ReadInt32(); var m_FontCountY = reader.ReadInt32(); } var m_Kerning = reader.ReadSingle(); var m_LineSpacing = reader.ReadSingle(); if (version[0] <= 3) { var m_PerCharacterKerning_size = reader.ReadInt32(); for (var i = 0; i < m_PerCharacterKerning_size; i++) { var first = reader.ReadInt32(); var second = reader.ReadSingle(); } } else { var m_CharacterSpacing = reader.ReadInt32(); var m_CharacterPadding = reader.ReadInt32(); } var m_ConvertCase = reader.ReadInt32(); var m_DefaultMaterial = new PPtr <Material>(reader); var m_CharacterRects_size = reader.ReadInt32(); for (var i = 0; i < m_CharacterRects_size; i++) { var index = reader.ReadInt32(); //Rectf uv var uvx = reader.ReadSingle(); var uvy = reader.ReadSingle(); var uvwidth = reader.ReadSingle(); var uvheight = reader.ReadSingle(); //Rectf vert var vertx = reader.ReadSingle(); var verty = reader.ReadSingle(); var vertwidth = reader.ReadSingle(); var vertheight = reader.ReadSingle(); var width = reader.ReadSingle(); if (version[0] >= 4) { var flipped = reader.ReadBoolean(); reader.AlignStream(); } } var m_Texture = new PPtr <Texture>(reader); var m_KerningValues_size = reader.ReadInt32(); for (var i = 0; i < m_KerningValues_size; i++) { int pairfirst = reader.ReadInt16(); int pairsecond = reader.ReadInt16(); var second = reader.ReadSingle(); } if (version[0] <= 3) { var m_GridFont = reader.ReadBoolean(); reader.AlignStream(); } else { var m_PixelScale = reader.ReadSingle(); } var m_FontData_size = reader.ReadInt32(); if (m_FontData_size > 0) { m_FontData = reader.ReadBytes(m_FontData_size); } } }
public List <uint> m_Indices = new List <uint>(); //use a list because I don't always know the facecount for triangle strips public Mesh(ObjectReader reader) : base(reader) { if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) //3.5 down { m_Use16BitIndices = reader.ReadInt32() > 0; } if (version[0] == 2 && version[1] <= 5) //2.5 and down { int m_IndexBuffer_size = reader.ReadInt32(); if (m_Use16BitIndices) { m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = reader.ReadUInt16(); } reader.AlignStream(); } else { m_IndexBuffer = reader.ReadUInt32Array(m_IndexBuffer_size / 4); } } int m_SubMeshesSize = reader.ReadInt32(); m_SubMeshes = new SubMesh[m_SubMeshesSize]; for (int i = 0; i < m_SubMeshesSize; i++) { m_SubMeshes[i] = new SubMesh(reader); } if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up { m_Shapes = new BlendShapeData(reader); } if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up { m_BindPose = reader.ReadMatrixArray(); m_BoneNameHashes = reader.ReadUInt32Array(); var m_RootBoneNameHash = reader.ReadUInt32(); } if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and up { if (version[0] >= 2019) //2019 and up { var m_BonesAABBSize = reader.ReadInt32(); var m_BonesAABB = new MinMaxAABB[m_BonesAABBSize]; for (int i = 0; i < m_BonesAABBSize; i++) { m_BonesAABB[i] = new MinMaxAABB(reader); } var m_VariableBoneCountWeights = reader.ReadUInt32Array(); } var m_MeshCompression = reader.ReadByte(); if (version[0] >= 4) { if (version[0] < 5) { var m_StreamCompression = reader.ReadByte(); } var m_IsReadable = reader.ReadBoolean(); var m_KeepVertices = reader.ReadBoolean(); var m_KeepIndices = reader.ReadBoolean(); } reader.AlignStream(); //Unity fixed it in 2017.3.1p1 and later versions if ((version[0] > 2017 || (version[0] == 2017 && version[1] >= 4)) || //2017.4 ((version[0] == 2017 && version[1] == 3 && version[2] == 1) && buildType.IsPatch) || //fixed after 2017.3.1px ((version[0] == 2017 && version[1] == 3) && m_MeshCompression == 0)) //2017.3.xfx with no compression { var m_IndexFormat = reader.ReadInt32(); } int m_IndexBuffer_size = reader.ReadInt32(); if (m_Use16BitIndices) { m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = reader.ReadUInt16(); } reader.AlignStream(); } else { m_IndexBuffer = reader.ReadUInt32Array(m_IndexBuffer_size / 4); } } if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) //3.4.2 and earlier { m_VertexCount = reader.ReadInt32(); m_Vertices = reader.ReadSingleArray(m_VertexCount * 3); //Vector3 m_Skin = new BoneWeights4[reader.ReadInt32()]; for (int s = 0; s < m_Skin.Length; s++) { m_Skin[s] = new BoneWeights4(reader); } m_BindPose = reader.ReadMatrixArray(); m_UV0 = reader.ReadSingleArray(reader.ReadInt32() * 2); //Vector2 m_UV1 = reader.ReadSingleArray(reader.ReadInt32() * 2); //Vector2 if (version[0] == 2 && version[1] <= 5) //2.5 and down { int m_TangentSpace_size = reader.ReadInt32(); m_Normals = new float[m_TangentSpace_size * 3]; m_Tangents = new float[m_TangentSpace_size * 4]; for (int v = 0; v < m_TangentSpace_size; v++) { m_Normals[v * 3] = reader.ReadSingle(); m_Normals[v * 3 + 1] = reader.ReadSingle(); m_Normals[v * 3 + 2] = reader.ReadSingle(); m_Tangents[v * 3] = reader.ReadSingle(); m_Tangents[v * 3 + 1] = reader.ReadSingle(); m_Tangents[v * 3 + 2] = reader.ReadSingle(); m_Tangents[v * 3 + 3] = reader.ReadSingle(); //handedness } } else //2.6.0 and later { m_Tangents = reader.ReadSingleArray(reader.ReadInt32() * 4); //Vector4 m_Normals = reader.ReadSingleArray(reader.ReadInt32() * 3); //Vector3 } } else { if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down { m_Skin = new BoneWeights4[reader.ReadInt32()]; for (int s = 0; s < m_Skin.Length; s++) { m_Skin[s] = new BoneWeights4(reader); } } if (version[0] == 3 || (version[0] == 4 && version[1] <= 2)) //4.2 and down { m_BindPose = reader.ReadMatrixArray(); } m_VertexData = new VertexData(reader); } if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and later { m_CompressedMesh = new CompressedMesh(reader); } reader.Position += 24; //AABB m_LocalAABB if (version[0] < 3 || (version[0] == 3 && version[1] <= 4)) //3.4.2 and earlier { int m_Colors_size = reader.ReadInt32(); m_Colors = new float[m_Colors_size * 4]; for (int v = 0; v < m_Colors_size * 4; v++) { m_Colors[v] = (float)reader.ReadByte() / 0xFF; } int m_CollisionTriangles_size = reader.ReadInt32(); reader.Position += m_CollisionTriangles_size * 4; //UInt32 indices int m_CollisionVertexCount = reader.ReadInt32(); } int m_MeshUsageFlags = reader.ReadInt32(); if (version[0] >= 5) //5.0 and up { var m_BakedConvexCollisionMesh = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(); var m_BakedTriangleCollisionMesh = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(); } if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up { var m_MeshMetrics = new float[2]; m_MeshMetrics[0] = reader.ReadSingle(); m_MeshMetrics[1] = reader.ReadSingle(); } if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 3)) //2018.3 and up { reader.AlignStream(); m_StreamData = new StreamingInfo(reader); } ProcessData(); }
public MiHoYoBinData(ObjectReader reader) : base(reader) { m_Data = reader.ReadBytes((int)reader.byteSize); }