Esempio n. 1
0
        private void ReadAssets(EndianReader reader)
        {
            AssemblyManager.Version = Version;

            HashSet <int> preloaded = new HashSet <int>();

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

                for (int i = 0; i < Metadata.Entries.Length; i++)
                {
                    if (Metadata.Entries[i].ClassID == ClassIDType.MonoScript)
                    {
                        if (preloaded.Add(i))
                        {
                            ReadAsset(assetReader, ref Metadata.Entries[i]);
                        }
                    }
                }

                for (int i = 0; i < Metadata.Entries.Length; i++)
                {
                    if (!preloaded.Contains(i))
                    {
                        ReadAsset(assetReader, ref Metadata.Entries[i]);
                    }
                }
            }
        }
Esempio n. 2
0
        internal void ReadData(Stream stream)
        {
            using (AssetReader assetReader = new AssetReader(stream, GetEndianType(), Layout))
            {
                if (SerializedFileMetadata.HasPreload(Header.Generation))
                {
                    foreach (ObjectPtr ptr in Metadata.Preloads)
                    {
                        if (ptr.FileID == 0)
                        {
                            int index = m_assetEntryLookup[ptr.PathID];
                            ReadAsset(assetReader, ref Metadata.Entries[index]);
                        }
                    }
                }

                for (int i = 0; i < Metadata.Entries.Length; i++)
                {
                    if (Metadata.Entries[i].ClassID == ClassIDType.MonoScript)
                    {
                        if (!m_assets.ContainsKey(Metadata.Entries[i].PathID))
                        {
                            ReadAsset(assetReader, ref Metadata.Entries[i]);
                        }
                    }
                }

                for (int i = 0; i < Metadata.Entries.Length; i++)
                {
                    if (!m_assets.ContainsKey(Metadata.Entries[i].PathID))
                    {
                        ReadAsset(assetReader, ref Metadata.Entries[i]);
                    }
                }
            }
        }