Beispiel #1
0
        private static bool TryLoadDependency(AssetCollection collection, IEnumerable <string> directories, string originalName, string loadName)
        {
            foreach (string dirPath in directories)
            {
                string path = Path.Combine(dirPath, loadName);
#if !DEBUG_PROGRAM
                try
#endif
                {
                    if (FileMultiStream.Exists(path))
                    {
                        using (Stream stream = FileMultiStream.OpenRead(path))
                        {
                            collection.Read(stream, path, originalName);
                        }

                        Logger.Instance.Log(LogType.Info, LogCategory.Import, $"Dependency '{path}' was loaded");
                        return(true);
                    }
                }
#if !DEBUG_PROGRAM
                catch (Exception ex)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Import, $"Can't parse dependency file {path}");
                    Logger.Instance.Log(LogType.Error, LogCategory.Debug, ex.ToString());
                }
#endif
            }
            return(false);
        }
Beispiel #2
0
 private void LoadFile(string fullFilePath, string originalFileName)
 {
     if (m_knownFiles.Add(originalFileName))
     {
         string filePath = FileMultiStream.GetFilePath(fullFilePath);
         using (Stream stream = FileMultiStream.OpenRead(filePath))
         {
             m_collection.Read(stream, filePath, originalFileName);
         }
     }
 }
Beispiel #3
0
        public ResourcesFile FindResourcesFile(ISerializedFile ifile, string fileName)
        {
            SerializedFile file = (SerializedFile)ifile;

            const string archivePrefix = "archive:/";

            if (fileName.StartsWith(archivePrefix))
            {
                fileName = Path.GetFileName(fileName);
            }

            // check assets 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);
        }
Beispiel #4
0
        private static void LoadFiles(AssetCollection collection, IEnumerable <string> filePathes)
        {
            List <string> processed = new List <string>();

            foreach (string path in filePathes)
            {
                string filePath = FileMultiStream.GetFilePath(path);
                if (processed.Contains(filePath))
                {
                    continue;
                }

                string fileName = FileMultiStream.GetFileName(path);
                using (Stream stream = FileMultiStream.OpenRead(path))
                {
                    collection.Read(stream, filePath, fileName);
                }
                processed.Add(filePath);
            }
        }