public SerializedProgram(ObjectReader reader) { var version = reader.version; int numSubPrograms = reader.ReadInt32(); m_SubPrograms = new SerializedSubProgram[numSubPrograms]; for (int i = 0; i < numSubPrograms; i++) { m_SubPrograms[i] = new SerializedSubProgram(reader); } if ((version[0] == 2020 && version[1] > 3) || (version[0] == 2020 && version[1] == 3 && version[2] >= 2) || //2020.3.2f1 and up (version[0] == 2021 && version[1] > 1) || (version[0] == 2021 && version[1] == 1 && version[2] >= 4)) //2021.1.4f1 and up { m_CommonParameters = new SerializedProgramParameters(reader); } }
public VideoClip(ObjectReader reader) : 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 || (version[0] == 2017 && version[1] >= 2)) //2017.2 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(); var m_AudioChannelCount = reader.ReadUInt16Array(); reader.AlignStream(); var m_AudioSampleRate = reader.ReadUInt32Array(); var m_AudioLanguage = reader.ReadStringArray(); //StreamedResource m_ExternalResources m_Source = reader.ReadAlignedString(); var m_Offset = reader.ReadUInt64(); m_Size = reader.ReadUInt64(); var m_HasSplitAlpha = reader.ReadBoolean(); ResourceReader resourceReader; if (!string.IsNullOrEmpty(m_Source)) { resourceReader = new ResourceReader(m_Source, assetsFile, (long)m_Offset, (int)m_Size); } else { resourceReader = new ResourceReader(reader, reader.BaseStream.Position, (int)m_Size); } m_VideoData = resourceReader; }
public LayerConstant(ObjectReader reader) { var version = reader.version; m_StateMachineIndex = reader.ReadUInt32(); m_StateMachineMotionSetIndex = reader.ReadUInt32(); m_BodyMask = new HumanPoseMask(reader); m_SkeletonMask = new SkeletonMask(reader); m_Binding = reader.ReadUInt32(); m_LayerBlendingMode = reader.ReadInt32(); if (version[0] > 4 || (version[0] == 4 && version[1] >= 2)) //4.2 and up { m_DefaultWeight = reader.ReadSingle(); } m_IKPass = reader.ReadBoolean(); if (version[0] > 4 || (version[0] == 4 && version[1] >= 2)) //4.2 and up { m_SyncedLayerAffectsTiming = reader.ReadBoolean(); } reader.AlignStream(); }
public GenericBinding(ObjectReader reader) { var version = reader.version; path = reader.ReadUInt32(); attribute = reader.ReadUInt32(); script = new PPtr <Object>(reader); if (version[0] > 5 || (version[0] == 5 && version[1] >= 6)) //5.6 and up { typeID = (ClassIDType)reader.ReadInt32(); } else { typeID = (ClassIDType)reader.ReadUInt16(); } customType = reader.ReadByte(); isPPtrCurve = reader.ReadByte(); if (version[0] > 2022 || (version[0] == 2022 && version[1] >= 1)) //2022.1 and up { isIntCurve = reader.ReadByte(); } reader.AlignStream(); }
public GLTextureSettings(ObjectReader reader) { var version = reader.version; m_FilterMode = reader.ReadInt32(); m_Aniso = reader.ReadInt32(); m_MipBias = reader.ReadSingle(); if (version[0] >= 2017) //2017.x and up { m_WrapMode = reader.ReadInt32(); //m_WrapU int m_WrapV = reader.ReadInt32(); int m_WrapW = reader.ReadInt32(); } else { m_WrapMode = reader.ReadInt32(); } }
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 Blend1dDataConstant(ObjectReader reader) { m_ChildThresholdArray = reader.ReadSingleArray(reader.ReadInt32()); }
public LeafInfoConstant(ObjectReader reader) { m_IDArray = reader.ReadUInt32Array(reader.ReadInt32()); m_IndexOffset = reader.ReadUInt32(); }
public MotionNeighborList(ObjectReader reader) { m_NeighborArray = reader.ReadUInt32Array(reader.ReadInt32()); }
//public AnimationEvent[] m_Events; public AnimationClip(ObjectReader reader) : base(reader) { if (version[0] >= 5)//5.0 and up { m_Legacy = reader.ReadBoolean(); } else if (version[0] >= 4)//4.0 and up { m_AnimationType = (AnimationType)reader.ReadInt32(); if (m_AnimationType == AnimationType.kLegacy) { m_Legacy = true; } } else { m_Legacy = true; } m_Compressed = reader.ReadBoolean(); if (version[0] > 4 || (version[0] == 4 && version[1] >= 3))//4.3 and up { m_UseHighQualityCurve = reader.ReadBoolean(); } reader.AlignStream(); int numRCurves = reader.ReadInt32(); m_RotationCurves = new QuaternionCurve[numRCurves]; for (int i = 0; i < numRCurves; i++) { m_RotationCurves[i] = new QuaternionCurve(reader); } int numCRCurves = reader.ReadInt32(); m_CompressedRotationCurves = new CompressedAnimationCurve[numCRCurves]; for (int i = 0; i < numCRCurves; i++) { m_CompressedRotationCurves[i] = new CompressedAnimationCurve(reader); } if (version[0] > 5 || (version[0] == 5 && version[1] >= 3))//5.3 and up { int numEulerCurves = reader.ReadInt32(); m_EulerCurves = new Vector3Curve[numEulerCurves]; for (int i = 0; i < numEulerCurves; i++) { m_EulerCurves[i] = new Vector3Curve(reader); } } int numPCurves = reader.ReadInt32(); m_PositionCurves = new Vector3Curve[numPCurves]; for (int i = 0; i < numPCurves; i++) { m_PositionCurves[i] = new Vector3Curve(reader); } int numSCurves = reader.ReadInt32(); m_ScaleCurves = new Vector3Curve[numSCurves]; for (int i = 0; i < numSCurves; i++) { m_ScaleCurves[i] = new Vector3Curve(reader); } int numFCurves = reader.ReadInt32(); m_FloatCurves = new FloatCurve[numFCurves]; for (int i = 0; i < numFCurves; i++) { m_FloatCurves[i] = new FloatCurve(reader); } if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up { int numPtrCurves = reader.ReadInt32(); m_PPtrCurves = new PPtrCurve[numPtrCurves]; for (int i = 0; i < numPtrCurves; i++) { m_PPtrCurves[i] = new PPtrCurve(reader); } } m_SampleRate = reader.ReadSingle(); m_WrapMode = reader.ReadInt32(); if (version[0] > 3 || (version[0] == 3 && version[1] >= 4)) //3.4 and up { m_Bounds = new AABB(reader); } if (version[0] >= 4)//4.0 and up { m_MuscleClipSize = reader.ReadUInt32(); m_MuscleClip = new ClipMuscleConstant(reader); } if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up { m_ClipBindingConstant = new AnimationClipBindingConstant(reader); } //m_HasGenericRootTransform 2018.3 //m_HasMotionFloatCurves 2018.3 /*int numEvents = reader.ReadInt32(); * m_Events = new AnimationEvent[numEvents]; * for (int i = 0; i < numEvents; i++) * { * m_Events[i] = new AnimationEvent(reader); * }*/ }
public SerializedSubProgram(ObjectReader reader) { var version = reader.version; m_BlobIndex = reader.ReadUInt32(); m_Channels = new ParserBindChannels(reader); m_KeywordIndices = reader.ReadUInt16Array(); if (version[0] >= 2017) //2017 and up { reader.AlignStream(); } m_ShaderHardwareTier = reader.ReadSByte(); m_GpuProgramType = (ShaderGpuProgramType)reader.ReadSByte(); reader.AlignStream(); int numVectorParams = reader.ReadInt32(); m_VectorParams = new VectorParameter[numVectorParams]; for (int i = 0; i < numVectorParams; i++) { m_VectorParams[i] = new VectorParameter(reader); } int numMatrixParams = reader.ReadInt32(); m_MatrixParams = new MatrixParameter[numMatrixParams]; for (int i = 0; i < numMatrixParams; i++) { m_MatrixParams[i] = new MatrixParameter(reader); } int numTextureParams = reader.ReadInt32(); m_TextureParams = new TextureParameter[numTextureParams]; for (int i = 0; i < numTextureParams; i++) { m_TextureParams[i] = new TextureParameter(reader); } int numBufferParams = reader.ReadInt32(); m_BufferParams = new BufferBinding[numBufferParams]; for (int i = 0; i < numBufferParams; i++) { m_BufferParams[i] = new BufferBinding(reader); } int numConstantBuffers = reader.ReadInt32(); m_ConstantBuffers = new ConstantBuffer[numConstantBuffers]; for (int i = 0; i < numConstantBuffers; i++) { m_ConstantBuffers[i] = new ConstantBuffer(reader); } int numConstantBufferBindings = reader.ReadInt32(); m_ConstantBufferBindings = new BufferBinding[numConstantBufferBindings]; for (int i = 0; i < numConstantBufferBindings; i++) { m_ConstantBufferBindings[i] = new BufferBinding(reader); } int numUAVParams = reader.ReadInt32(); m_UAVParams = new UAVParameter[numUAVParams]; for (int i = 0; i < numUAVParams; i++) { m_UAVParams[i] = new UAVParameter(reader); } if (version[0] >= 2017) //2017 and up { int numSamplers = reader.ReadInt32(); m_Samplers = new SamplerParameter[numSamplers]; for (int i = 0; i < numSamplers; i++) { m_Samplers[i] = new SamplerParameter(reader); } } if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up { var m_ShaderRequirements = reader.ReadInt32(); } }
private int index = -2; //-2 - Prepare, -1 - Missing public PPtr(ObjectReader reader) { m_FileID = reader.ReadInt32(); m_PathID = reader.m_Version < 14 ? reader.ReadInt32() : reader.ReadInt64(); assetsFile = reader.assetsFile; }
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 Texture2D(ObjectReader reader) : 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(); if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up { var m_StreamingMipmapsPriority = reader.ReadInt32(); } else if (HasStructMember("m_StreamingMipmapsPriority")) //will fix in some patch version bundle { var m_StreamingMipmapsPriority = reader.ReadInt32(); } if (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(); } ResourceReader resourceReader; if (!string.IsNullOrEmpty(path)) { resourceReader = new ResourceReader(path, assetsFile, offset, image_data_size); } else { resourceReader = new ResourceReader(reader, reader.BaseStream.Position, image_data_size); } image_data = new Lazy <byte[]>(resourceReader.GetData); }
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 SerializedProgramParameters(ObjectReader reader) { int numVectorParams = reader.ReadInt32(); m_VectorParams = new VectorParameter[numVectorParams]; for (int i = 0; i < numVectorParams; i++) { m_VectorParams[i] = new VectorParameter(reader); } int numMatrixParams = reader.ReadInt32(); m_MatrixParams = new MatrixParameter[numMatrixParams]; for (int i = 0; i < numMatrixParams; i++) { m_MatrixParams[i] = new MatrixParameter(reader); } int numTextureParams = reader.ReadInt32(); m_TextureParams = new TextureParameter[numTextureParams]; for (int i = 0; i < numTextureParams; i++) { m_TextureParams[i] = new TextureParameter(reader); } int numBufferParams = reader.ReadInt32(); m_BufferParams = new BufferBinding[numBufferParams]; for (int i = 0; i < numBufferParams; i++) { m_BufferParams[i] = new BufferBinding(reader); } int numConstantBuffers = reader.ReadInt32(); m_ConstantBuffers = new ConstantBuffer[numConstantBuffers]; for (int i = 0; i < numConstantBuffers; i++) { m_ConstantBuffers[i] = new ConstantBuffer(reader); } int numConstantBufferBindings = reader.ReadInt32(); m_ConstantBufferBindings = new BufferBinding[numConstantBufferBindings]; for (int i = 0; i < numConstantBufferBindings; i++) { m_ConstantBufferBindings[i] = new BufferBinding(reader); } int numUAVParams = reader.ReadInt32(); m_UAVParams = new UAVParameter[numUAVParams]; for (int i = 0; i < numUAVParams; i++) { m_UAVParams[i] = new UAVParameter(reader); } int numSamplers = reader.ReadInt32(); m_Samplers = new SamplerParameter[numSamplers]; for (int i = 0; i < numSamplers; i++) { m_Samplers[i] = new SamplerParameter(reader); } }
public Node(ObjectReader reader) { m_ParentId = reader.ReadInt32(); m_AxesId = reader.ReadInt32(); }
public ClipMuscleConstant(ObjectReader reader) { var version = reader.version; m_DeltaPose = new HumanPose(reader); m_StartX = new xform(reader); if (version[0] > 5 || (version[0] == 5 && version[1] >= 5))//5.5 and up { m_StopX = new xform(reader); } m_LeftFootStartX = new xform(reader); m_RightFootStartX = new xform(reader); if (version[0] < 5)//5.0 down { m_MotionStartX = new xform(reader); m_MotionStopX = new xform(reader); } m_AverageSpeed = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4();//5.4 and up m_Clip = new Clip(reader); m_StartTime = reader.ReadSingle(); m_StopTime = reader.ReadSingle(); m_OrientationOffsetY = reader.ReadSingle(); m_Level = reader.ReadSingle(); m_CycleOffset = reader.ReadSingle(); m_AverageAngularSpeed = reader.ReadSingle(); int numIndices = reader.ReadInt32(); m_IndexArray = reader.ReadInt32Array(numIndices); if (version[0] < 4 || (version[0] == 4 && version[1] < 3)) //4.3 down { int numAdditionalCurveIndexs = reader.ReadInt32(); var m_AdditionalCurveIndexArray = new List <int>(numAdditionalCurveIndexs); for (int i = 0; i < numAdditionalCurveIndexs; i++) { m_AdditionalCurveIndexArray.Add(reader.ReadInt32()); } } int numDeltas = reader.ReadInt32(); m_ValueArrayDelta = new List <ValueDelta>(numDeltas); for (int i = 0; i < numDeltas; i++) { m_ValueArrayDelta.Add(new ValueDelta(reader)); } if (version[0] > 5 || (version[0] == 5 && version[1] >= 3))//5.3 and up { m_ValueArrayReferencePose = reader.ReadSingleArray(reader.ReadInt32()); } m_Mirror = reader.ReadBoolean(); m_LoopTime = reader.ReadBoolean(); m_LoopBlend = reader.ReadBoolean(); m_LoopBlendOrientation = reader.ReadBoolean(); m_LoopBlendPositionY = reader.ReadBoolean(); m_LoopBlendPositionXZ = reader.ReadBoolean(); if (version[0] > 5 || (version[0] == 5 && version[1] >= 5))//5.5 and up { m_StartAtOrigin = reader.ReadBoolean(); } m_KeepOriginalOrientation = reader.ReadBoolean(); m_KeepOriginalPositionY = reader.ReadBoolean(); m_KeepOriginalPositionXZ = reader.ReadBoolean(); m_HeightFromFeet = reader.ReadBoolean(); reader.AlignStream(4); }
public ConstantClip(ObjectReader reader) { int numData = reader.ReadInt32(); data = reader.ReadSingleArray(numData); }
//public List<AnimationEvent> m_Events { get; set; } public AnimationClip(ObjectReader reader) : base(reader) { if (version[0] >= 5)//5.0 and up { m_Legacy = reader.ReadBoolean(); } else if (version[0] >= 4)//4.0 and up { m_AnimationType = (AnimationType)reader.ReadInt32(); if (m_AnimationType == AnimationType.kLegacy) { m_Legacy = true; } } else { m_Legacy = true; } m_Compressed = reader.ReadBoolean(); if (version[0] > 4 || (version[0] == 4 && version[1] >= 3))//4.3 and up { m_UseHighQualityCurve = reader.ReadBoolean(); } reader.AlignStream(4); int numRCurves = reader.ReadInt32(); m_RotationCurves = new List <QuaternionCurve>(numRCurves); for (int i = 0; i < numRCurves; i++) { m_RotationCurves.Add(new QuaternionCurve(reader)); } int numCRCurves = reader.ReadInt32(); m_CompressedRotationCurves = new List <CompressedAnimationCurve>(numCRCurves); for (int i = 0; i < numCRCurves; i++) { m_CompressedRotationCurves.Add(new CompressedAnimationCurve(reader)); } if (version[0] > 5 || (version[0] == 5 && version[1] >= 3))//5.3 and up { int numEulerCurves = reader.ReadInt32(); m_EulerCurves = new List <Vector3Curve>(numEulerCurves); for (int i = 0; i < numEulerCurves; i++) { m_EulerCurves.Add(new Vector3Curve(reader)); } } int numPCurves = reader.ReadInt32(); m_PositionCurves = new List <Vector3Curve>(numPCurves); for (int i = 0; i < numPCurves; i++) { m_PositionCurves.Add(new Vector3Curve(reader)); } int numSCurves = reader.ReadInt32(); m_ScaleCurves = new List <Vector3Curve>(numSCurves); for (int i = 0; i < numSCurves; i++) { m_ScaleCurves.Add(new Vector3Curve(reader)); } int numFCurves = reader.ReadInt32(); m_FloatCurves = new List <FloatCurve>(numFCurves); for (int i = 0; i < numFCurves; i++) { m_FloatCurves.Add(new FloatCurve(reader)); } if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up { int numPtrCurves = reader.ReadInt32(); m_PPtrCurves = new List <PPtrCurve>(numPtrCurves); for (int i = 0; i < numPtrCurves; i++) { m_PPtrCurves.Add(new PPtrCurve(reader)); } } m_SampleRate = reader.ReadSingle(); m_WrapMode = reader.ReadInt32(); if (version[0] > 3 || (version[0] == 3 && version[1] >= 4)) //3.4 and up { m_Bounds = new AABB(reader); } if (version[0] >= 4)//4.0 and up { m_MuscleClipSize = reader.ReadUInt32(); m_MuscleClip = new ClipMuscleConstant(reader); } if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up { m_ClipBindingConstant = new AnimationClipBindingConstant(reader); } /*int numEvents = reader.ReadInt32(); * m_Events = new List<AnimationEvent>(numEvents); * for (int i = 0; i < numEvents; i++) * { * m_Events.Add(new AnimationEvent(stream, file.Version[0] - '0')); * }*/ }
public BlendDirectDataConstant(ObjectReader reader) { m_ChildBlendEventIDArray = reader.ReadUInt32Array(reader.ReadInt32()); m_NormalizedBlendValues = reader.ReadBoolean(); reader.AlignStream(4); }
protected Renderer(ObjectReader reader) : 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(); } 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(); } 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 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 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(); } }
private int index = -2; //-2 - Prepare, -1 - Missing public PPtr(ObjectReader reader) { m_FileID = reader.ReadInt32(); m_PathID = reader.m_Version < SerializedFileFormatVersion.Unknown_14 ? reader.ReadInt32() : reader.ReadInt64(); assetsFile = reader.assetsFile; }
public StateConstant(ObjectReader reader) { var version = reader.version; int numTransistions = reader.ReadInt32(); m_TransitionConstantArray = new TransitionConstant[numTransistions]; for (int i = 0; i < numTransistions; i++) { m_TransitionConstantArray[i] = new TransitionConstant(reader); } m_BlendTreeConstantIndexArray = reader.ReadInt32Array(); if (version[0] < 5 || (version[0] == 5 && version[1] < 2)) //5.2 down { int numInfos = reader.ReadInt32(); m_LeafInfoArray = new LeafInfoConstant[numInfos]; for (int i = 0; i < numInfos; i++) { m_LeafInfoArray[i] = new LeafInfoConstant(reader); } } int numBlends = reader.ReadInt32(); m_BlendTreeConstantArray = new BlendTreeConstant[numBlends]; for (int i = 0; i < numBlends; i++) { m_BlendTreeConstantArray[i] = new BlendTreeConstant(reader); } m_NameID = reader.ReadUInt32(); if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up { m_PathID = reader.ReadUInt32(); } if (version[0] >= 5) //5.0 and up { m_FullPathID = reader.ReadUInt32(); } m_TagID = reader.ReadUInt32(); if (version[0] > 5 || (version[0] == 5 && version[1] >= 1)) //5.1 and up { m_SpeedParamID = reader.ReadUInt32(); m_MirrorParamID = reader.ReadUInt32(); m_CycleOffsetParamID = reader.ReadUInt32(); } if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up { var m_TimeParamID = reader.ReadUInt32(); } m_Speed = reader.ReadSingle(); if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up { m_CycleOffset = reader.ReadSingle(); } m_IKOnFeet = reader.ReadBoolean(); if (version[0] >= 5) //5.0 and up { m_WriteDefaultValues = reader.ReadBoolean(); } m_Loop = reader.ReadBoolean(); if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up { m_Mirror = reader.ReadBoolean(); } reader.AlignStream(); }
private static void DumpType(TypeSig typeSig, StringBuilder sb, ObjectReader reader, string name, int indent, bool isRoot = false, bool align = true) { var typeDef = typeSig.ToTypeDefOrRef().ResolveTypeDefThrow(); if (typeSig.IsPrimitive) { object value = null; switch (typeSig.TypeName) { case "Boolean": value = reader.ReadBoolean(); break; case "Byte": value = reader.ReadByte(); break; case "SByte": value = reader.ReadSByte(); break; case "Int16": value = reader.ReadInt16(); break; case "UInt16": value = reader.ReadUInt16(); break; case "Int32": value = reader.ReadInt32(); break; case "UInt32": value = reader.ReadUInt32(); break; case "Int64": value = reader.ReadInt64(); break; case "UInt64": value = reader.ReadUInt64(); break; case "Single": value = reader.ReadSingle(); break; case "Double": value = reader.ReadDouble(); break; case "Char": value = reader.ReadChar(); break; } if (align) { reader.AlignStream(); } sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name} = {value}"); return; } if (typeSig.FullName == "System.String") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name} = \"{reader.ReadAlignedString()}\""); return; } if (typeSig.FullName == "System.Object") { return; } if (typeDef.IsDelegate) { return; } if (typeSig is ArraySigBase) { if (!typeDef.IsEnum && !IsBaseType(typeDef) && !IsAssignFromUnityObject(typeDef) && !IsEngineType(typeDef) && !typeDef.IsSerializable) { return; } var size = reader.ReadInt32(); sb.AppendLine($"{new string('\t', indent)}{typeSig.TypeName} {name}"); sb.AppendLine($"{new string('\t', indent + 1)}int size = {size}"); for (int i = 0; i < size; i++) { sb.AppendLine($"{new string('\t', indent + 2)}[{i}]"); DumpType(typeDef.ToTypeSig(), sb, reader, "data", indent + 2); } return; } if (!isRoot && typeSig is GenericInstSig genericInstSig) { if (genericInstSig.GenericArguments.Count == 1) { var genericType = genericInstSig.GenericType.ToTypeDefOrRef().ResolveTypeDefThrow(); var type = genericInstSig.GenericArguments[0].ToTypeDefOrRef().ResolveTypeDefThrow(); if (genericInstSig.GenericArguments[0] is ArraySigBase) { return; } if (!type.IsEnum && !IsBaseType(type) && !IsAssignFromUnityObject(type) && !IsEngineType(type) && !type.IsSerializable) { return; } sb.AppendLine($"{new string('\t', indent)}{typeSig.TypeName} {name}"); if (genericType.Interfaces.Any(x => x.Interface.FullName == "System.Collections.Generic.ICollection`1<T>")) //System.Collections.Generic.IEnumerable`1<T> { var size = reader.ReadInt32(); sb.AppendLine($"{new string('\t', indent + 1)}int size = {size}"); for (int i = 0; i < size; i++) { sb.AppendLine($"{new string('\t', indent + 2)}[{i}]"); DumpType(genericInstSig.GenericArguments[0], sb, reader, "data", indent + 2, false, false); } reader.AlignStream(); } else { DumpType(genericType.ToTypeSig(), sb, reader, "data", indent + 1); } } return; } if (indent != -1 && IsAssignFromUnityObject(typeDef)) { var pptr = new PPtr <Object>(reader); sb.AppendLine($"{new string('\t', indent)}PPtr<{typeDef.Name}> {name} = {{fileID: {pptr.m_FileID}, pathID: {pptr.m_PathID}}}"); return; } if (typeDef.IsEnum) { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name} = {reader.ReadUInt32()}"); return; } if (!isRoot && !IsEngineType(typeDef) && !typeDef.IsSerializable) { return; } if (typeDef.FullName == "UnityEngine.Rect") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var prefix = new string('\t', indent + 1); sb.AppendLine($"{prefix}float x = {reader.ReadSingle()}"); sb.AppendLine($"{prefix}float y = {reader.ReadSingle()}"); sb.AppendLine($"{prefix}float width = {reader.ReadSingle()}"); sb.AppendLine($"{prefix}float height = {reader.ReadSingle()}"); return; } if (typeDef.FullName == "UnityEngine.LayerMask") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); sb.AppendLine($"{new string('\t', indent + 1)}uint m_Bits = {reader.ReadUInt32()}"); return; } if (typeDef.FullName == "UnityEngine.AnimationCurve") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); sb.AppendLine($"{new string('\t', indent + 1)}<truncated>"); var animationCurve = new AnimationCurve <float>(reader, reader.ReadSingle); return; } if (typeDef.FullName == "UnityEngine.Gradient") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); sb.AppendLine($"{new string('\t', indent + 1)}<truncated>"); if (reader.version[0] == 5 && reader.version[1] < 5) { reader.Position += 68; } else if (reader.version[0] == 5 && reader.version[1] < 6) { reader.Position += 72; } else { reader.Position += 168; } return; } if (typeDef.FullName == "UnityEngine.RectOffset") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var prefix = new string('\t', indent + 1); sb.AppendLine($"{prefix}float left = {reader.ReadSingle()}"); sb.AppendLine($"{prefix}float right = {reader.ReadSingle()}"); sb.AppendLine($"{prefix}float top = {reader.ReadSingle()}"); sb.AppendLine($"{prefix}float bottom = {reader.ReadSingle()}"); return; } if (typeDef.FullName == "UnityEngine.PropertyName") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); sb.AppendLine($"{new string('\t', indent + 1)}int id = {reader.ReadInt32()}"); return; } if (typeDef.FullName == "UnityEngine.Color32") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var prefix = new string('\t', indent + 1); sb.AppendLine($"{prefix}byte r = {reader.ReadByte()}"); sb.AppendLine($"{prefix}byte g = {reader.ReadByte()}"); sb.AppendLine($"{prefix}byte b = {reader.ReadByte()}"); sb.AppendLine($"{prefix}byte a = {reader.ReadByte()}"); reader.AlignStream(); return; } if (typeDef.FullName == "UnityEngine.Vector2Int") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var prefix = new string('\t', indent + 1); sb.AppendLine($"{prefix}int x = {reader.ReadInt32()}"); sb.AppendLine($"{prefix}int y = {reader.ReadInt32()}"); return; } if (typeDef.FullName == "UnityEngine.Vector3Int") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var prefix = new string('\t', indent + 1); sb.AppendLine($"{prefix}int x = {reader.ReadInt32()}"); sb.AppendLine($"{prefix}int y = {reader.ReadInt32()}"); sb.AppendLine($"{prefix}int z = {reader.ReadInt32()}"); return; } if (typeDef.FullName == "UnityEngine.Bounds") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); sb.AppendLine($"{new string('\t', indent + 1)}<truncated>"); new AABB(reader); return; } if (typeDef.FullName == "UnityEngine.GUIStyle") //TODO { throw new NotSupportedException(); } if (typeDef.IsClass || typeDef.IsValueType) { if (name != null && indent != -1) { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); } if (indent == -1 && typeDef.BaseType.FullName != "UnityEngine.Object") { DumpType(typeDef.BaseType.ToTypeSig(), sb, reader, null, indent, true); } if (indent != -1 && typeDef.BaseType.FullName != "System.Object") { DumpType(typeDef.BaseType.ToTypeSig(), sb, reader, null, indent, true); } foreach (var fieldDef in typeDef.Fields) { var flag = false; var access = fieldDef.Access & FieldAttributes.FieldAccessMask; if (access != FieldAttributes.Public) { if (fieldDef.CustomAttributes.Any(x => x.TypeFullName == "UnityEngine.SerializeField")) { flag = true; } } else if ((fieldDef.Attributes & FieldAttributes.Static) == 0 && (fieldDef.Attributes & FieldAttributes.InitOnly) == 0 && (fieldDef.Attributes & FieldAttributes.NotSerialized) == 0) { flag = true; } if (flag) { if (fieldDef.FieldType.IsGenericParameter) { for (var i = 0; i < typeDef.GenericParameters.Count; i++) { var g = typeDef.GenericParameters[i]; if (g.FullName == fieldDef.FieldType.FullName) { var type = ((GenericInstSig)typeSig).GenericArguments[i]; DumpType(type, sb, reader, fieldDef.Name, indent + 1); break; } } } else { DumpType(fieldDef.FieldType, sb, reader, fieldDef.Name, indent + 1); } } } } }
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 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 Texture2D(ObjectReader reader) : base(reader) { m_Width = reader.ReadInt32(); m_Height = reader.ReadInt32(); var m_CompleteImageSize = reader.ReadInt32(); if (version[0] >= 2020) //2020.1 and up { var m_MipsStripped = reader.ReadInt32(); } m_TextureFormat = (TextureFormat)reader.ReadInt32(); if (version[0] < 5 || (version[0] == 5 && version[1] < 2)) //5.2 down { m_MipMap = reader.ReadBoolean(); } else { m_MipCount = reader.ReadInt32(); } if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and up { var m_IsReadable = reader.ReadBoolean(); } if (version[0] >= 2020) //2020.1 and up { var m_IsPreProcessed = reader.ReadBoolean(); } if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up { var m_IgnoreMasterTextureLimit = reader.ReadBoolean(); } if (version[0] >= 3) //3.0.0 - 5.4 { if (version[0] < 5 || (version[0] == 5 && version[1] <= 4)) { var m_ReadAllowed = reader.ReadBoolean(); } } if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up { var m_StreamingMipmaps = reader.ReadBoolean(); } reader.AlignStream(); if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up { var m_StreamingMipmapsPriority = reader.ReadInt32(); } var m_ImageCount = reader.ReadInt32(); var m_TextureDimension = reader.ReadInt32(); m_TextureSettings = new GLTextureSettings(reader); if (version[0] >= 3) //3.0 and up { var m_LightmapFormat = reader.ReadInt32(); } if (version[0] > 3 || (version[0] == 3 && version[1] >= 5)) //3.5.0 and up { var m_ColorSpace = reader.ReadInt32(); } if (version[0] > 2020 || (version[0] == 2020 && version[1] >= 2)) //2020.2 and up { var m_PlatformBlob = reader.ReadUInt8Array(); reader.AlignStream(); } var image_data_size = reader.ReadInt32(); if (image_data_size == 0 && ((version[0] == 5 && version[1] >= 3) || version[0] > 5))//5.3.0 and up { m_StreamData = new StreamingInfo(reader); } ResourceReader resourceReader; if (!string.IsNullOrEmpty(m_StreamData?.path)) { // no way in hell this is correct reader.AlignStream(); resourceReader = new ResourceReader(reader, reader.BaseStream.Length - m_CompleteImageSize, m_CompleteImageSize); //resourceReader = new ResourceReader(m_StreamData.path, assetsFile, m_StreamData.offset, m_StreamData.size); } else { resourceReader = new ResourceReader(reader, reader.BaseStream.Position, image_data_size); } image_data = resourceReader; }
private static void DumpType(TypeSig typeSig, StringBuilder sb, ObjectReader reader, string name, int indent, bool isRoot = false) { var typeDef = typeSig.ToTypeDefOrRef().ResolveTypeDefThrow(); if (typeSig.IsPrimitive) { object value = null; switch (typeSig.TypeName) { case "Boolean": value = reader.ReadBoolean(); break; case "Byte": value = reader.ReadByte(); break; case "SByte": value = reader.ReadSByte(); break; case "Int16": value = reader.ReadInt16(); break; case "UInt16": value = reader.ReadUInt16(); break; case "Int32": value = reader.ReadInt32(); break; case "UInt32": value = reader.ReadUInt32(); break; case "Int64": value = reader.ReadInt64(); break; case "UInt64": value = reader.ReadUInt64(); break; case "Single": value = reader.ReadSingle(); break; case "Double": value = reader.ReadDouble(); break; case "Char": value = reader.ReadChar(); break; } reader.AlignStream(4); sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name} = {value}"); return; } if (typeSig.FullName == "System.String") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name} = \"{reader.ReadAlignedString()}\""); return; } if (typeSig.FullName == "System.Object") { return; } if (typeDef.IsDelegate) { return; } if (typeSig is ArraySigBase) { if (!typeDef.IsEnum && !IsBaseType(typeDef) && !IsAssignFromUnityObject(typeDef) && !IsEngineType(typeDef) && !typeDef.IsSerializable) { return; } var size = reader.ReadInt32(); sb.AppendLine($"{new string('\t', indent)}{typeSig.TypeName} {name}"); sb.AppendLine($"{new string('\t', indent + 1)}Array Array"); sb.AppendLine($"{new string('\t', indent + 1)}int size = {size}"); for (int i = 0; i < size; i++) { sb.AppendLine($"{new string('\t', indent + 2)}[{i}]"); DumpType(typeDef.ToTypeSig(), sb, reader, "data", indent + 2); } return; } if (!isRoot && typeSig is GenericInstSig genericInstSig) { if (genericInstSig.GenericArguments.Count == 1) { var type = genericInstSig.GenericArguments[0].ToTypeDefOrRef().ResolveTypeDefThrow(); if (!type.IsEnum && !IsBaseType(type) && !IsAssignFromUnityObject(type) && !IsEngineType(type) && !type.IsSerializable) { return; } var size = reader.ReadInt32(); sb.AppendLine($"{new string('\t', indent)}{typeSig.TypeName} {name}"); sb.AppendLine($"{new string('\t', indent + 1)}Array Array"); sb.AppendLine($"{new string('\t', indent + 1)}int size = {size}"); for (int i = 0; i < size; i++) { sb.AppendLine($"{new string('\t', indent + 2)}[{i}]"); DumpType(genericInstSig.GenericArguments[0], sb, reader, "data", indent + 2); } } return; } if (indent != -1 && IsAssignFromUnityObject(typeDef)) { var pptr = reader.ReadPPtr(); sb.AppendLine($"{new string('\t', indent)}PPtr<{typeDef.Name}> {name} = {{fileID: {pptr.m_FileID}, pathID: {pptr.m_PathID}}}"); return; } if (typeDef.IsEnum) { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name} = {reader.ReadUInt32()}"); return; } if (indent != -1 && !IsEngineType(typeDef) && !typeDef.IsSerializable) { return; } if (typeDef.FullName == "UnityEngine.Rect") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var rect = reader.ReadSingleArray(4); return; } if (typeDef.FullName == "UnityEngine.LayerMask") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var value = reader.ReadInt32(); return; } if (typeDef.FullName == "UnityEngine.AnimationCurve") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var animationCurve = new AnimationCurve <float>(reader, reader.ReadSingle); return; } if (typeDef.FullName == "UnityEngine.Gradient") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); if (reader.version[0] == 5 && reader.version[1] < 5) { reader.Position += 68; } else if (reader.version[0] == 5 && reader.version[1] < 6) { reader.Position += 72; } else { reader.Position += 168; } return; } if (typeDef.FullName == "UnityEngine.RectOffset") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var left = reader.ReadSingle(); var right = reader.ReadSingle(); var top = reader.ReadSingle(); var bottom = reader.ReadSingle(); return; } if (typeDef.FullName == "UnityEngine.GUIStyle") //TODO { throw new NotSupportedException(); } if (typeDef.IsClass || typeDef.IsValueType) { if (name != null && indent != -1) { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); } if (indent == -1 && typeDef.BaseType.FullName != "UnityEngine.Object") { DumpType(typeDef.BaseType.ToTypeSig(), sb, reader, null, indent, true); } if (indent != -1 && typeDef.BaseType.FullName != "System.Object") { DumpType(typeDef.BaseType.ToTypeSig(), sb, reader, null, indent, true); } foreach (var fieldDef in typeDef.Fields) { var access = fieldDef.Access & FieldAttributes.FieldAccessMask; if (access != FieldAttributes.Public) { if (fieldDef.CustomAttributes.Any(x => x.TypeFullName.Contains("SerializeField"))) { DumpType(fieldDef.FieldType, sb, reader, fieldDef.Name, indent + 1); } } else if ((fieldDef.Attributes & FieldAttributes.Static) == 0 && (fieldDef.Attributes & FieldAttributes.InitOnly) == 0 && (fieldDef.Attributes & FieldAttributes.NotSerialized) == 0) { DumpType(fieldDef.FieldType, sb, reader, fieldDef.Name, indent + 1); } } } }
public Material(ObjectReader reader) : base(reader) { m_Shader = reader.ReadPPtr(); if (version[0] == 4 && (version[1] >= 2 || (version[1] == 1 && buildType[0] != "a"))) { m_ShaderKeywords = new string[reader.ReadInt32()]; for (int i = 0; i < m_ShaderKeywords.Length; i++) { m_ShaderKeywords[i] = reader.ReadAlignedString(); } } else if (version[0] >= 5)//5.0 and up { m_ShaderKeywords = new[] { reader.ReadAlignedString() }; uint m_LightmapFlags = reader.ReadUInt32(); if (version[0] == 5 && version[1] >= 6 || version[0] > 5)//5.6.0 and up { var m_EnableInstancingVariants = reader.ReadBoolean(); //var m_DoubleSidedGI = a_Stream.ReadBoolean();//2017.x reader.AlignStream(4); } } if (version[0] > 4 || version[0] == 4 && version[1] >= 3) { m_CustomRenderQueue = reader.ReadInt32(); } if (version[0] == 5 && version[1] >= 1 || version[0] > 5)//5.1 and up { string[][] stringTagMap = new string[reader.ReadInt32()][]; for (int i = 0; i < stringTagMap.Length; i++) { stringTagMap[i] = new[] { reader.ReadAlignedString(), reader.ReadAlignedString() }; } } //disabledShaderPasses if ((version[0] == 5 && version[1] >= 6) || version[0] > 5)//5.6.0 and up { var size = reader.ReadInt32(); for (int i = 0; i < size; i++) { reader.ReadAlignedString(); } } //m_SavedProperties m_TexEnvs = new TexEnv[reader.ReadInt32()]; for (int i = 0; i < m_TexEnvs.Length; i++) { TexEnv m_TexEnv = new TexEnv() { name = reader.ReadAlignedString(), m_Texture = reader.ReadPPtr(), m_Scale = new[] { reader.ReadSingle(), reader.ReadSingle() }, m_Offset = new[] { reader.ReadSingle(), reader.ReadSingle() } }; m_TexEnvs[i] = m_TexEnv; } m_Floats = new strFloatPair[reader.ReadInt32()]; for (int i = 0; i < m_Floats.Length; i++) { strFloatPair m_Float = new strFloatPair() { first = reader.ReadAlignedString(), second = reader.ReadSingle() }; m_Floats[i] = m_Float; } m_Colors = new strColorPair[reader.ReadInt32()]; for (int i = 0; i < m_Colors.Length; i++) { strColorPair m_Color = new strColorPair() { first = reader.ReadAlignedString(), second = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() } }; m_Colors[i] = m_Color; } }