예제 #1
0
        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))
            {
                if (SerializedFileMetadata.IsReadPreload(Header.Generation))
                {
                    foreach (ObjectPtr ptr in Metadata.Preloads)
                    {
                        if (ptr.FileID == 0)
                        {
                            ObjectInfo info = Metadata.Objects[ptr.PathID];
                            ReadAsset(ustream, info, startPosition);
                            preloaded.Add(ptr.PathID);
                        }
                    }
                }

                foreach (ObjectInfo info in Metadata.Objects.Values)
                {
                    if (!preloaded.Contains(info.PathID))
                    {
                        ReadAsset(ustream, info, startPosition);
                    }
                }
            }
        }
예제 #2
0
        public SerializedFile(IFileCollection collection, string filePath, string fileName)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            Collection = collection;
            FilePath   = filePath;
            Name       = fileName.ToLower();

            Header   = new SerializedFileHeader(Name);
            Metadata = new SerializedFileMetadata(Name);
        }
        public SerializedFile(FileCollection collection, string name, string filePath, TransferInstructionFlags flags)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException(nameof(filePath));
            }

            m_collection = collection;
            FilePath     = filePath;
            Name         = FilenameUtils.FixFileIdentifier(name);
            Flags        = flags;

            Header   = new SerializedFileHeader(Name);
            Metadata = new SerializedFileMetadata(Name);
        }
예제 #4
0
        public SerializedFile(IFileCollection collection, string filePath, string fileName, TransferInstructionFlags flags)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            Collection = collection;
            FilePath   = filePath;
            Name       = fileName.ToLower(CultureInfo.InvariantCulture);
            Flags      = flags;

            Header   = new SerializedFileHeader(Name);
            Metadata = new SerializedFileMetadata(Name);
        }
        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);
                    }
                }
            }
        }
예제 #6
0
        private SerializedFile(IFileCollection collection, IAssemblyManager manager, string filePath, string name, TransferInstructionFlags flags)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException(nameof(filePath));
            }

            Collection      = collection;
            AssemblyManager = manager;
            FilePath        = filePath;
            Name            = FilenameUtils.FixFileIdentifier(name);
            Flags           = flags == TransferInstructionFlags.NoTransferInstructionFlags ? GetCompiledTransferFlag() : flags;

            Header   = new SerializedFileHeader(Name);
            Metadata = new SerializedFileMetadata(Name);
        }