コード例 #1
0
        public ResourcesFile FindResourcesFile(ISerializedFile ifile, string resName)
        {
            SerializedFile file = (SerializedFile)ifile;

            resName = FilenameUtils.FixResourcePath(resName);

            // check asset bundles / web files
            string filePath = file.FilePath;

            foreach (ResourcesFile res in m_resources)
            {
                if (res.FilePath == filePath && res.Name == resName)
                {
                    return(res.CreateReference());
                }
            }

            string resPath = m_resourceCallback?.Invoke(resName);

            if (resPath == null)
            {
                return(null);
            }
            using (SmartStream stream = SmartStream.OpenRead(resPath))
            {
                return(new ResourcesFile(stream, resPath, resName, 0, stream.Length));
            }
        }
コード例 #2
0
        public DependencyCollection(FileCollection fileCollection, IEnumerable <FileEntry> entries, Action <string> dependencyCallback)
        {
            if (fileCollection == null)
            {
                throw new ArgumentNullException(nameof(fileCollection));
            }
            if (entries == null)
            {
                throw new ArgumentNullException(nameof(entries));
            }
            if (dependencyCallback == null)
            {
                throw new ArgumentNullException(nameof(dependencyCallback));
            }

            m_fileCollection = fileCollection;
            Dictionary <string, FileEntry> fileEntries = new Dictionary <string, FileEntry>();

            foreach (FileEntry entry in entries)
            {
                string name = FilenameUtils.FixFileIdentifier(entry.Name);
                fileEntries.Add(name, entry);
            }
            m_entries            = fileEntries;
            m_dependencyCallback = dependencyCallback;
        }
コード例 #3
0
        public void ReadFiles()
        {
            foreach (FileEntry entry in m_entries.Values)
            {
                if (entry.EntryType == FileEntryType.Resource)
                {
                    entry.ReadResourcesFile(m_fileCollection);
                }
            }

            foreach (FileEntry entry in m_entries.Values)
            {
                if (entry.EntryType == FileEntryType.Serialized)
                {
                    string name = FilenameUtils.FixFileIdentifier(entry.Name);
                    if (m_loadedFiles.Add(name))
                    {
                        entry.ReadSerializedFile(m_fileCollection, OnRequestDependency);
                    }
                }
            }

            foreach (FileEntry entry in m_entries.Values)
            {
                if (entry.EntryType == FileEntryType.Bundle)
                {
                    entry.ReadBundleFile(m_fileCollection);
                }
                else if (entry.EntryType == FileEntryType.Web)
                {
                    entry.ReadWebFile(m_fileCollection);
                }
            }
        }
コード例 #4
0
        public bool RequestDependency(string dependency)
        {
            if (Files.TryGetValue(dependency, out string dependencyPath))
            {
                LoadDependency(dependency, dependencyPath);
                return(true);
            }

            foreach (string dataPath in DataPathes)
            {
                string filePath = Path.Combine(dataPath, dependency);
                if (FileMultiStream.Exists(filePath))
                {
                    LoadDependency(dependency, filePath);
                    return(true);
                }

                if (FilenameUtils.IsDefaultResource(dependency))
                {
                    if (LoadEngineDependency(dataPath, FilenameUtils.DefaultResourceName1))
                    {
                        return(true);
                    }
                    if (LoadEngineDependency(dataPath, FilenameUtils.DefaultResourceName2))
                    {
                        return(true);
                    }
                }
                else if (FilenameUtils.IsBuiltinExtra(dependency))
                {
                    if (LoadEngineDependency(dataPath, FilenameUtils.BuiltinExtraName1))
                    {
                        return(true);
                    }
                    if (LoadEngineDependency(dataPath, FilenameUtils.BuiltinExtraName2))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #5
0
        public bool RequestAssembly(string assembly)
        {
            string fixedAssembly = FilenameUtils.FixAssemblyName(assembly);

            if (PlatformStructure != null)
            {
                if (PlatformStructure.RequestAssembly(assembly))
                {
                    return(true);
                }
            }
            if (MixedStructure != null)
            {
                if (MixedStructure.RequestAssembly(assembly))
                {
                    return(true);
                }
            }

            Logger.Instance.Log(LogType.Warning, LogCategory.Import, $"Assembly '{assembly}' hasn't been found");
            return(false);
        }
コード例 #6
0
        public ResourcesFile FindResourcesFile(ISerializedFile ifile, string fileName)
        {
            SerializedFile file = (SerializedFile)ifile;

            fileName = FilenameUtils.FixResourcePath(fileName);

            // check asset bundles / web files
            string filePath = file.FilePath;

            foreach (ResourcesFile res in m_resources)
            {
                if (res.FilePath == filePath && res.Name == fileName)
                {
                    return(res);
                }
            }

            // check manualy loaded resource files
            string dirPath = Path.GetDirectoryName(filePath) ?? string.Empty;
            string resPath = Path.Combine(dirPath, fileName);

            foreach (ResourcesFile res in m_resources)
            {
                if (res.FilePath == resPath && res.Name == fileName)
                {
                    return(res);
                }
            }

            // lazy loading
            if (FileMultiStream.Exists(resPath))
            {
                Stream        stream    = FileMultiStream.OpenRead(resPath);
                ResourcesFile resesFile = new ResourcesFile(resPath, fileName, stream);
                m_resources.Add(resesFile);
                return(resesFile);
            }
            return(null);
        }