public void Read(SerializedFileStream stream)
        {
            ClassID = (ClassIDType)stream.ReadInt32();
            if (IsReadUnknown(stream.Generation))
            {
                Unknown  = stream.ReadByte();
                ScriptID = stream.ReadInt16();
            }

            if (IsReadHash(stream.Generation))
            {
                if (IsOldHashType(stream.Generation))
                {
                    if ((int)ClassID <= -1)
                    {
                        ScriptHash.Read(stream);
                    }
                }
                else
                {
                    if (ClassID == ClassIDType.MonoBehaviour)
                    {
                        ScriptHash.Read(stream);
                    }
                }
                TypeHash.Read(stream);
            }

            // isSerializeTypeTrees
            if (Tree != null)
            {
                Tree.Read(stream);
            }
        }
示例#2
0
        public void Read(SerializedFileStream stream)
        {
            if (IsReadSignature(stream.Generation))
            {
                string signature = stream.ReadStringZeroTerm();
                Version.Parse(signature);
            }
            if (IsReadAttributes(stream.Generation))
            {
                Platform = (Platform)stream.ReadUInt32();
                if (!Enum.IsDefined(typeof(Platform), Platform))
                {
                    throw new Exception($"Unsuported platform {Platform} for asset file '{Name}'");
                }
            }
            if (IsReadSerializeTypeTrees(stream.Generation))
            {
                SerializeTypeTrees = stream.ReadBoolean();
            }
            else
            {
                SerializeTypeTrees = true;
            }
            m_types = stream.ReadArray(() => new RTTIBaseClassDescriptor(SerializeTypeTrees));

            if (IsReadUnknown(stream.Generation))
            {
                Unknown = stream.ReadInt32();
            }
        }
示例#3
0
        public void Read(SerializedFileStream stream)
        {
            if (IsRead5Format(stream.Generation))
            {
                int nodesCount = stream.ReadInt32();
                if (nodesCount < 0)
                {
                    throw new Exception($"Invalid type tree's node count {nodesCount}");
                }

                int stringSize = stream.ReadInt32();
                if (stringSize < 0)
                {
                    throw new Exception($"Invalid type tree's string size {stringSize}");
                }

                m_nodes = new TypeTreeNode[nodesCount];
                long stringPosition = stream.BaseStream.Position + nodesCount * TypeTreeNode.NodeSize;
                for (int i = 0; i < nodesCount; i++)
                {
                    TypeTreeNode node = new TypeTreeNode();
                    node.Read(stream, stringPosition);
                    m_nodes[i] = node;
                }
                stream.BaseStream.Position += stringSize;
            }
            else
            {
                List <TypeTreeNode> nodes = new List <TypeTreeNode>();
                ReadTreeNode(stream, nodes, 0);
                m_nodes = nodes.ToArray();
            }
        }
示例#4
0
 public void Read(SerializedFileStream stream)
 {
     Type     = stream.ReadStringZeroTerm();
     Name     = stream.ReadStringZeroTerm();
     ByteSize = stream.ReadInt32();
     Index    = stream.ReadInt32();
     IsArray  = stream.ReadInt32() != 0;
     Version  = stream.ReadInt32();
     MetaFlag = stream.ReadUInt32();
 }
        public void Read(Stream baseStream, Action <string> requestDependencyCallback)
        {
            using (EndianStream stream = new EndianStream(baseStream, baseStream.Position, EndianType.BigEndian))
            {
                long startPosition = baseStream.Position;
                Header.Read(stream);

                stream.EndianType = Header.Endianess ? EndianType.BigEndian : EndianType.LittleEndian;
                if (IsTableAtTheEnd(Header.Generation))
                {
                    stream.BaseStream.Position = startPosition + Header.FileSize - Header.MetadataSize;
                    stream.BaseStream.Position++;
                }

                using (SerializedFileStream fileStream = new SerializedFileStream(stream, Header.Generation))
                {
                    Metadata.Read(fileStream);
                }

                foreach (FileIdentifier dependency in Dependencies)
                {
                    requestDependencyCallback?.Invoke(dependency.FilePath);
                }

                if (RTTIClassHierarchyDescriptor.IsReadSignature(Header.Generation))
                {
                    ReadAssets(stream, startPosition);
                }
                else
                {
                    Logger.Log(LogType.Warning, LogCategory.Import, $"Can't determine file version for generation {Header.Generation} for file '{Name}'");
                    string[] versions = GetGenerationVersions(Header.Generation);
                    for (int i = 0; i < versions.Length; i++)
                    {
                        string version = versions[i];
                        Logger.Log(LogType.Debug, LogCategory.Import, $"Try parse {nameof(SerializedFile)} as {version} version");
                        Version.Parse(version);
                        try
                        {
                            ReadAssets(stream, startPosition);
                            break;
                        }
                        catch
                        {
                            Logger.Log(LogType.Debug, LogCategory.Import, "Faild");
                            if (i == versions.Length - 1)
                            {
                                throw;
                            }
                        }
                    }
                }
            }
        }
 public void Read(SerializedFileStream stream)
 {
     if (IsReadAssetName(stream.Generation))
     {
         AssetPath = stream.ReadStringZeroTerm();
     }
     if (IsReadHash(stream.Generation))
     {
         Hash.Read(stream);
         Type = (AssetType)stream.ReadInt32();
     }
     FilePath = stream.ReadStringZeroTerm();
 }
 public void Read(SerializedFileStream stream)
 {
     if (IsReadAssetName(stream.Generation))
     {
         AssetPath = stream.ReadStringZeroTerm();
     }
     if (IsReadHash(stream.Generation))
     {
         Hash.Read(stream);
         Type = (AssetType)stream.ReadInt32();
     }
     FilePathOrigin = stream.ReadStringZeroTerm();
     FilePath       = FilenameUtils.FixFileIdentifier(FilePathOrigin);
 }
示例#8
0
        private static void ReadTreeNode(SerializedFileStream stream, ICollection <TypeTreeNode> nodes, byte depth)
        {
            TypeTreeNode node = new TypeTreeNode(depth);

            node.Read(stream);
            nodes.Add(node);

            int childCount = stream.ReadInt32();

            for (int i = 0; i < childCount; i++)
            {
                ReadTreeNode(stream, nodes, (byte)(depth + 1));
            }
        }
示例#9
0
        public void Read(SerializedFileStream stream, long stringPosition)
        {
            Version = stream.ReadUInt16();
            Depth   = stream.ReadByte();
            IsArray = stream.ReadBoolean();
            uint type = stream.ReadUInt32();
            uint name = stream.ReadUInt32();

            ByteSize = stream.ReadInt32();
            Index    = stream.ReadInt32();
            MetaFlag = stream.ReadUInt32();

            Type = ReadString(stream, stringPosition, type);
            Name = ReadString(stream, stringPosition, name);
        }
示例#10
0
        private static string ReadString(SerializedFileStream stream, long stringPosition, uint value)
        {
            bool isCustomType = (value & 0x80000000) == 0;

            if (isCustomType)
            {
                long position = stream.BaseStream.Position;
                stream.BaseStream.Position = stringPosition + value;
                string stringValue = stream.ReadStringZeroTerm();
                stream.BaseStream.Position = position;
                return(stringValue);
            }
            else
            {
                uint         type     = value & 0x7FFFFFFF;
                TreeNodeType nodeType = (TreeNodeType)type;
                if (!Enum.IsDefined(typeof(TreeNodeType), nodeType))
                {
                    throw new Exception($"Unsupported asset class type name '{nodeType}''");
                }
                return(nodeType.ToTypeString());
            }
        }
        public void Read(SerializedFileStream stream)
        {
            Hierarchy.Read(stream);

            int count = stream.ReadInt32();

            m_objects = new Dictionary <long, ObjectInfo>(count);
            for (int i = 0; i < count; i++)
            {
                ObjectInfo objectInfo = new ObjectInfo();
                objectInfo.Read(stream);
                m_objects.Add(objectInfo.PathID, objectInfo);
            }

            if (IsReadPreload(stream.Generation))
            {
                m_preloads = stream.ReadArray <ObjectPtr>();
            }
            m_dependencies = stream.ReadArray <FileIdentifier>();
            if (IsReadUnknown(stream.Generation))
            {
                Unknown = stream.ReadStringZeroTerm();
            }
        }