Beispiel #1
0
        public void Read(UnityBinaryReader reader)
        {
            // Read Header
            Header.Read(reader);

            // Only Supports version = 17
            if (Header.Version != 17)
            {
                throw new NotSupportedException("Version " + Header.Version.ToString() + " is not supported");
            }
            // Only Supports LittleEndian
            if (Header.IsBigEndian)
            {
                throw new NotSupportedException("BigEndian file is not supported");
            }

            // Read Metadata
            readMetadata(reader);

            // Read Objects
            readObjects(reader);

            // Read Scripts
            readScripts(reader);

            // Read Externals
            readExternals(reader);

            // Read UserInformation
            UserInformation = reader.ReadStringToNull();
        }
        /// <summary>
        /// Read AssetBundle from binary using UnityBinaryReader.
        /// </summary>
        /// <remarks>Start of AssetBundle must be on the start Position of the reader.</remarks>
        /// <exception cref="UnknownFormatException">Format of given AssetBundle is not supported.</exception>
        /// <param name="reader">UnityBinaryReader to read from.</param>
        public void Read(UnityBinaryReader reader)
        {
            Header.Read(reader);

            // Only supports UnityFS
            if (Header.signature != "UnityFS")
            {
                throw new UnknownFormatException("Signature " + Header.signature + " is not supported");
            }
            // Only supports format6
            if (Header.format != FORMAT)
            {
                throw new UnknownFormatException("Format " + Header.format.ToString() + " is not supported");
            }

            readFiles(reader);
        }