Exemple #1
0
        public AudioClip(AssetPreloadData preloadData, bool readData) : base(preloadData)
        {
            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 (preloadData.Size + preloadData.Offset - 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);
                    }
                }
            }
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
        public AudioClip(AssetPreloadData preloadData, bool readSwitch, Dictionary <string, EndianBinaryReader> resourceFileReaders)
        {
            var sourceFile = preloadData.sourceFile;
            var reader     = preloadData.InitReader();

            m_Name   = reader.ReadAlignedString();
            version5 = sourceFile.version[0] >= 5;
            if (sourceFile.version[0] < 5)
            {
                m_Format      = reader.ReadInt32(); //channels?
                m_Type        = (AudioType)reader.ReadInt32();
                m_3D          = reader.ReadBoolean();
                m_UseHardware = reader.ReadBoolean();
                reader.AlignStream(4);

                if (sourceFile.version[0] >= 4 || (sourceFile.version[0] == 3 && sourceFile.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;
                    //TODO: Need more test
                    if (preloadData.Size + preloadData.Offset - reader.Position != tsize)
                    {
                        m_Offset = reader.ReadInt32();
                        m_Source = sourceFile.filePath + ".resS";
                    }
                }
                else
                {
                    m_Size = reader.ReadInt32();
                }
            }
            else
            {
                m_LoadType        = reader.ReadInt32(); //Decompress on load, Compressed in memory, Streaming
                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 (readSwitch)
            {
                if (!string.IsNullOrEmpty(m_Source))
                {
                    m_AudioData = ResourcesHelper.GetData(m_Source, sourceFile.filePath, m_Offset, (int)m_Size, resourceFileReaders);
                }
                else
                {
                    if (m_Size > 0)
                    {
                        m_AudioData = reader.ReadBytes((int)m_Size);
                    }
                }
            }
            else
            {
                preloadData.InfoText = "Compression format: ";

                if (sourceFile.version[0] < 5)
                {
                    switch (m_Type)
                    {
                    case AudioType.ACC:
                        preloadData.extension = ".m4a";
                        preloadData.InfoText += "Acc";
                        break;

                    case AudioType.AIFF:
                        preloadData.extension = ".aif";
                        preloadData.InfoText += "AIFF";
                        break;

                    case AudioType.IT:
                        preloadData.extension = ".it";
                        preloadData.InfoText += "Impulse tracker";
                        break;

                    case AudioType.MOD:
                        preloadData.extension = ".mod";
                        preloadData.InfoText += "Protracker / Fasttracker MOD";
                        break;

                    case AudioType.MPEG:
                        preloadData.extension = ".mp3";
                        preloadData.InfoText += "MP2/MP3 MPEG";
                        break;

                    case AudioType.OGGVORBIS:
                        preloadData.extension = ".ogg";
                        preloadData.InfoText += "Ogg vorbis";
                        break;

                    case AudioType.S3M:
                        preloadData.extension = ".s3m";
                        preloadData.InfoText += "ScreamTracker 3";
                        break;

                    case AudioType.WAV:
                        preloadData.extension = ".wav";
                        preloadData.InfoText += "Microsoft WAV";
                        break;

                    case AudioType.XM:
                        preloadData.extension = ".xm";
                        preloadData.InfoText += "FastTracker 2 XM";
                        break;

                    case AudioType.XMA:
                        preloadData.extension = ".wav";
                        preloadData.InfoText += "Xbox360 XMA";
                        break;

                    case AudioType.VAG:
                        preloadData.extension = ".vag";
                        preloadData.InfoText += "PlayStation Portable ADPCM";
                        break;

                    case AudioType.AUDIOQUEUE:
                        preloadData.extension = ".fsb";
                        preloadData.InfoText += "iPhone";
                        break;
                    }
                }
                else
                {
                    switch (m_CompressionFormat)
                    {
                    case AudioCompressionFormat.PCM:
                        preloadData.extension = ".fsb";
                        preloadData.InfoText += "PCM";
                        break;

                    case AudioCompressionFormat.Vorbis:
                        preloadData.extension = ".fsb";
                        preloadData.InfoText += "Vorbis";
                        break;

                    case AudioCompressionFormat.ADPCM:
                        preloadData.extension = ".fsb";
                        preloadData.InfoText += "ADPCM";
                        break;

                    case AudioCompressionFormat.MP3:
                        preloadData.extension = ".fsb";
                        preloadData.InfoText += "MP3";
                        break;

                    case AudioCompressionFormat.VAG:
                        preloadData.extension = ".vag";
                        preloadData.InfoText += "PlayStation Portable ADPCM";
                        break;

                    case AudioCompressionFormat.HEVAG:
                        preloadData.extension = ".vag";
                        preloadData.InfoText += "PSVita ADPCM";
                        break;

                    case AudioCompressionFormat.XMA:
                        preloadData.extension = ".wav";
                        preloadData.InfoText += "Xbox360 XMA";
                        break;

                    case AudioCompressionFormat.AAC:
                        preloadData.extension = ".m4a";
                        preloadData.InfoText += "AAC";
                        break;

                    case AudioCompressionFormat.GCADPCM:
                        preloadData.extension = ".fsb";
                        preloadData.InfoText += "Nintendo 3DS/Wii DSP";
                        break;

                    case AudioCompressionFormat.ATRAC9:
                        preloadData.extension = ".at9";
                        preloadData.InfoText += "PSVita ATRAC9";
                        break;
                    }
                }

                if (preloadData.extension == null)
                {
                    preloadData.extension = ".AudioClip";
                    preloadData.InfoText += "Unknown";
                }

                preloadData.InfoText += "\n3D: " + m_3D;

                preloadData.FullName = m_Name;
                if (m_Source != null)
                {
                    preloadData.fullSize = preloadData.Size + (int)m_Size;
                }
            }
        }
        public Texture2D(AssetPreloadData preloadData, bool readSwitch)
        {
            this.preloadData = preloadData;
            var sourceFile = preloadData.sourceFile;
            var reader     = preloadData.InitReader();
            var version    = sourceFile.version;

            m_Name = reader.ReadAlignedString();
            if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3))//2017.3 and up
            {
                var m_ForcedFallbackFormat = reader.ReadInt32();
                var m_DownscaleFallback    = reader.ReadBoolean();
                reader.AlignStream(4);
            }
            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 (preloadData.HasStructMember("m_StreamingMipmapsPriority")) //will fix in some patch version bundle
            {
                var m_StreamingMipmapsPriority = reader.ReadInt32();
            }
            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 (readSwitch)
            {
                if (!string.IsNullOrEmpty(path))
                {
                    image_data = ResourcesHelper.GetData(path, sourceFile.filePath, offset, image_data_size);
                }
                else
                {
                    image_data = reader.ReadBytes(image_data_size);
                }
            }
            else
            {
                preloadData.InfoText = $"Width: {m_Width}\nHeight: {m_Height}\nFormat: {m_TextureFormat}";

                switch (m_FilterMode)
                {
                case 0: preloadData.InfoText += "\nFilter Mode: Point "; break;

                case 1: preloadData.InfoText += "\nFilter Mode: Bilinear "; break;

                case 2: preloadData.InfoText += "\nFilter Mode: Trilinear "; break;
                }

                preloadData.InfoText += $"\nAnisotropic level: {m_Aniso}\nMip map bias: {m_MipBias}";

                switch (m_WrapMode)
                {
                case 0: preloadData.InfoText += "\nWrap mode: Repeat"; break;

                case 1: preloadData.InfoText += "\nWrap mode: Clamp"; break;
                }

                preloadData.Text = m_Name;
                if (!string.IsNullOrEmpty(path))
                {
                    preloadData.fullSize = preloadData.Size + (int)size;
                }
            }
        }
Exemple #5
0
        public VideoClip(AssetPreloadData preloadData, bool readSwitch)
        {
            var sourceFile = preloadData.sourceFile;
            var reader     = preloadData.InitReader();

            m_Name = reader.ReadAlignedString();
            var m_OriginalPath = reader.ReadAlignedString();
            var m_ProxyWidth   = reader.ReadUInt32();
            var m_ProxyHeight  = reader.ReadUInt32();
            var Width          = reader.ReadUInt32();
            var Height         = reader.ReadUInt32();

            if (sourceFile.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
            var m_Source        = reader.ReadAlignedString();
            var m_Offset        = reader.ReadUInt64();
            var m_Size          = reader.ReadUInt64();
            var m_HasSplitAlpha = reader.ReadBoolean();

            if (readSwitch)
            {
                if (!string.IsNullOrEmpty(m_Source))
                {
                    m_VideoData = ResourcesHelper.GetData(m_Source, sourceFile.filePath, (long)m_Offset, (int)m_Size);
                }
                else
                {
                    if (m_Size > 0)
                    {
                        m_VideoData = reader.ReadBytes((int)m_Size);
                    }
                }
            }
            else
            {
                preloadData.extension = Path.GetExtension(m_OriginalPath);
                preloadData.Text      = m_Name;
                preloadData.fullSize  = preloadData.Size + (int)m_Size;
            }
        }