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); } } }