private ClassIDType AssetEntryToClassIDType(AssetEntry info)
 {
     if (AssetEntry.IsReadTypeIndex(Header.Generation))
     {
         RTTIBaseClassDescriptor typemeta = Metadata.Hierarchy.Types[info.TypeIndex];
         return(typemeta.ClassID);
     }
     else
     {
         return(info.ClassID);
     }
 }
        private void ReadAsset(AssetStream stream, AssetEntry info, long startPosition)
        {
            long        pathID    = info.PathID;
            ClassIDType classID   = AssetEntryToClassIDType(info);
            AssetInfo   assetInfo = new AssetInfo(this, pathID, classID);
            Object      asset     = ReadAsset(stream, assetInfo, startPosition + Header.DataOffset + info.DataOffset, info.DataSize);

            if (asset != null)
            {
                AddAsset(pathID, asset);
            }
        }
        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);
            }
        }
        private void ReadAssets(EndianStream stream, long startPosition)
        {
            m_assets.Clear();
            HashSet <long> preloaded = new HashSet <long>();

            using (AssetStream ustream = new AssetStream(stream.BaseStream, Version, Platform, Flags))
            {
                if (SerializedFileMetadata.IsReadPreload(Header.Generation))
                {
                    foreach (ObjectPtr ptr in Metadata.Preloads)
                    {
                        if (ptr.FileID == 0)
                        {
                            AssetEntry info = Metadata.Objects[ptr.PathID];
                            ReadAsset(ustream, 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(ustream, infoPair.Value, startPosition);
                            preloaded.Add(infoPair.Key);
                        }
                    }
                }

                foreach (AssetEntry info in Metadata.Objects.Values)
                {
                    if (!preloaded.Contains(info.PathID))
                    {
                        ReadAsset(ustream, info, startPosition);
                    }
                }
            }
        }
        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();
            }
        }