Example #1
0
 public ObjectReader(EndianBinaryReader reader, SerializedFile assetsFile, ObjectInfo objectInfo) : base(reader.BaseStream, reader.endian)
 {
     this.assetsFile = assetsFile;
     m_PathID        = objectInfo.m_PathID;
     byteStart       = objectInfo.byteStart;
     byteSize        = objectInfo.byteSize;
     if (Enum.IsDefined(typeof(ClassIDType), objectInfo.classID))
     {
         type = (ClassIDType)objectInfo.classID;
     }
     else
     {
         type = ClassIDType.UnknownType;
     }
     serializedType = objectInfo.serializedType;
     platform       = assetsFile.m_TargetPlatform;
     m_Version      = assetsFile.header.m_Version;
 }
        private SerializedType ReadSerializedType()
        {
            var type = new SerializedType();

            type.classID = reader.ReadInt32();

            if (header.m_Version >= 16)
            {
                type.m_IsStrippedType = reader.ReadBoolean();
            }

            if (header.m_Version >= 17)
            {
                type.m_ScriptTypeIndex = reader.ReadInt16();
            }

            if (header.m_Version >= 13)
            {
                if ((header.m_Version < 16 && type.classID < 0) || (header.m_Version >= 16 && type.classID == 114))
                {
                    type.m_ScriptID = reader.ReadBytes(16); //Hash128
                }
                type.m_OldTypeHash = reader.ReadBytes(16);  //Hash128
            }

            if (m_EnableTypeTree)
            {
                var typeTree = new List <TypeTreeNode>();
                if (header.m_Version >= 12 || header.m_Version == 10)
                {
                    ReadTypeTree5(typeTree);
                }
                else
                {
                    //ReadTypeTree(typeTree);
                    throw new NotImplementedException();
                }

                type.m_Nodes = typeTree;
            }

            return(type);
        }