コード例 #1
0
        public void Read(SerializedFileReader reader)
        {
            Hierarchy.Read(reader);

            int count = reader.ReadInt32();
            Dictionary <long, AssetEntry> entries = new Dictionary <long, AssetEntry>(count);

            for (int i = 0; i < count; i++)
            {
                AssetEntry entry = new AssetEntry();
                entry.Read(reader, Hierarchy);
                entries.Add(entry.PathID, entry);
            }
            Entries = entries;

            if (IsReadPreload(reader.Generation))
            {
                Preloads = reader.ReadSerializedArray <ObjectPtr>();
            }
            Dependencies = reader.ReadSerializedArray <FileIdentifier>();
            if (IsReadUnknown(reader.Generation))
            {
                Unknown = reader.ReadStringZeroTerm();
            }
        }
コード例 #2
0
        private void ReadAsset(AssetReader reader, AssetEntry info)
        {
            AssetInfo assetInfo = new AssetInfo(this, info.PathID, info.ClassID);
            Object    asset     = ReadAsset(reader, assetInfo, Header.DataOffset + info.Offset, info.Size);

            if (asset != null)
            {
                AddAsset(info.PathID, asset);
            }
        }
コード例 #3
0
 private void ReadAsset(EndianReader reader, AssetEntry info, long startPosition)
 {
     long pathID = info.PathID;
     ClassIDType classID = AssetEntryToClassIDType(info);
     AssetInfo assetInfo = new AssetInfo(this, pathID, classID);
     Object asset = ReadAsset(reader, assetInfo, startPosition + Header.DataOffset + info.DataOffset, info.DataSize);
     if (asset != null)
     {
         AddAsset(pathID, asset);
     }
 }
コード例 #4
0
 private ClassIDType AssetEntryToClassIDType(AssetEntry info)
 {
     if (AssetEntry.IsReadTypeIndex(Header.Generation))
     {
         RTTIBaseClassDescriptor typemeta = Metadata.Hierarchy.Types[info.TypeIndex];
         return(typemeta.ClassID);
     }
     else
     {
         return(info.ClassID);
     }
 }
コード例 #5
0
 public ClassIDType GetClassID(long pathID)
 {
     AssetEntry info = Metadata.Objects[pathID];
     if (AssetEntry.IsReadTypeIndex(Header.Generation))
     {
         return Metadata.Hierarchy.Types[info.TypeIndex].ClassID;
     }
     else
     {
         return info.ClassID;
     }
 }
コード例 #6
0
        private void ReadAssets(EndianReader reader)
        {
            HashSet <long> preloaded = new HashSet <long>();

            using (AssetReader assetReader = new AssetReader(reader, Version, Platform, Flags))
            {
                if (SerializedFileMetadata.IsReadPreload(Header.Generation))
                {
                    foreach (ObjectPtr ptr in Metadata.Preloads)
                    {
                        if (ptr.FileID == 0)
                        {
                            AssetEntry info = Metadata.Entries[ptr.PathID];
                            ReadAsset(assetReader, info);
                            preloaded.Add(ptr.PathID);
                        }
                    }
                }

                foreach (KeyValuePair <long, AssetEntry> infoPair in Metadata.Entries)
                {
                    if (infoPair.Value.ClassID == ClassIDType.MonoScript)
                    {
                        if (!preloaded.Contains(infoPair.Key))
                        {
                            ReadAsset(assetReader, infoPair.Value);
                            preloaded.Add(infoPair.Key);
                        }
                    }
                }

                foreach (AssetEntry info in Metadata.Entries.Values)
                {
                    if (!preloaded.Contains(info.PathID))
                    {
                        ReadAsset(assetReader, info);
                    }
                }
            }
        }
コード例 #7
0
        private void ReadAssets(EndianReader reader, long startPosition)
        {
            HashSet <long> preloaded = new HashSet <long>();

            if (SerializedFileMetadata.IsReadPreload(Header.Generation))
            {
                foreach (ObjectPtr ptr in Metadata.Preloads)
                {
                    if (ptr.FileID == 0)
                    {
                        AssetEntry info = Metadata.Objects[ptr.PathID];
                        ReadAsset(reader, info, startPosition);
                        preloaded.Add(ptr.PathID);
                    }
                }
            }

            foreach (KeyValuePair <long, AssetEntry> infoPair in Metadata.Objects)
            {
                ClassIDType classID = AssetEntryToClassIDType(infoPair.Value);
                if (classID == ClassIDType.MonoScript)
                {
                    if (!preloaded.Contains(infoPair.Key))
                    {
                        ReadAsset(reader, infoPair.Value, startPosition);
                        preloaded.Add(infoPair.Key);
                    }
                }
            }

            foreach (AssetEntry info in Metadata.Objects.Values)
            {
                if (!preloaded.Contains(info.PathID))
                {
                    ReadAsset(reader, info, startPosition);
                }
            }
        }
コード例 #8
0
        public void Read(SerializedFileReader reader)
        {
            Hierarchy.Read(reader);

            int count = reader.ReadInt32();

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

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