Ejemplo n.º 1
0
        public SerializedType Parse(EndianBinaryReader varStream, bool varEnableTypeTree, SerializedFileFormatVersion varFormat, bool varRefType = false)
        {
            classID         = (PersistentTypeID)varStream.ReadInt32();
            IsStrippedType  = varStream.ReadBoolean();
            ScriptTypeIndex = varStream.ReadInt16();

            if (classID == PersistentTypeID.MonoBehaviour)
            {
                m_ScriptID = varStream.ReadBytes(16);
            }
            m_OldTypeHash = varStream.ReadBytes(16);

            if (varEnableTypeTree)
            {
                mTypeTree = new TypeTree().Parse(varStream, varFormat);

                if (varFormat >= SerializedFileFormatVersion.kStoresTypeDependencies)
                {
                    if (varRefType)
                    {
                        m_KlassName = varStream.ReadStringToNull();
                        m_NameSpace = varStream.ReadStringToNull();
                        m_AsmName   = varStream.ReadStringToNull();
                    }
                    else
                    {
                        m_TypeDependencies = varStream.ReadInt32Array();
                    }
                }
            }
            return(this);
        }
        public SerializedFile Parse(EndianBinaryReader varStream)
        {
            Header = new SerializedFileHeader().Parse(varStream);

            varStream.endian = (EndianType)Header.Endianess;

            UnityVersion = varStream.ReadStringToNull();

            var tempBuildTarget = varStream.ReadInt32();

            if (Enum.IsDefined(typeof(BuildTarget), tempBuildTarget))
            {
                TargetPlatform = (BuildTarget)tempBuildTarget;
            }

            EnableTypeTree = varStream.ReadBoolean();

            var tempTypeCount = varStream.ReadInt32();

            Types = new List <SerializedType>(tempTypeCount);
            for (int i = 0; i < tempTypeCount; ++i)
            {
                var tempType = new SerializedType().Parse(varStream, EnableTypeTree, Header.Version);
                Types.Add(tempType);
            }

            var tempObjCount = varStream.ReadInt32();

            ObjectMap = new Dictionary <long, ObjectInfo>(tempObjCount);
            for (int i = 0; i < tempObjCount; ++i)
            {
                var tempObjInfo = new ObjectInfo().Parse(varStream);
                ObjectMap.Add(tempObjInfo.LocalPathID, tempObjInfo);
            }

            var tempScriptCount = varStream.ReadInt32();

            ScriptTypes = new List <LocalSerializedObjectIdentifier>(tempScriptCount);
            for (int i = 0; i < tempScriptCount; ++i)
            {
                var tempScriptTyps = new LocalSerializedObjectIdentifier().Parse(varStream);
                ScriptTypes.Add(tempScriptTyps);
            }

            var tempExternalsCount = varStream.ReadInt32();

            FileIdentifiers = new List <FileIdentifier>(tempExternalsCount);
            for (int i = 0; i < tempExternalsCount; ++i)
            {
                var tempFileID = new FileIdentifier().Parse(varStream);
                FileIdentifiers.Add(tempFileID);
            }

            var tempRefTypesCount = varStream.ReadInt32();

            RefTypes = new List <SerializedType>(tempRefTypesCount);
            for (int i = 0; i < tempRefTypesCount; ++i)
            {
                var tempType = new SerializedType().Parse(varStream, EnableTypeTree, Header.Version, true);
                Types.Add(tempType);
            }

            userInformation = varStream.ReadStringToNull();

            if (varStream.Position < (int)Alignment.kMetadataAllocation)
            {
                varStream.Seek((int)Alignment.kMetadataAllocation - varStream.Position, SeekOrigin.Current);
            }
            else
            {
                varStream.AlignStream((int)Alignment.kSectionAlignment);
            }

            return(this);
        }