Ejemplo n.º 1
0
        private async Task LoadAllMetaDataForLoader(AssetBundleLoader loader, bool createIfNotExisting = false)
        {
            var sw = Stopwatch.StartNew();

            await Task.Run(async() =>
            {
                foreach (var assetMetaPath in await _customSaberAssetLoader.CollectFiles())
                {
                    var relativePath = PathTools.ToRelativePath(assetMetaPath.MetaDataPath);
                    if (_metaData.TryGetValue(relativePath, out _))
                    {
                        continue;
                    }

                    if (!assetMetaPath.HasMetaData)
                    {
                        if (createIfNotExisting)
                        {
                            var comp = await await UnityMainThreadTaskScheduler.Factory.StartNew(() => this[PathTools.ToRelativePath(assetMetaPath.Path)]);

                            if (comp == null)
                            {
                                continue;
                            }

                            var metaData = new PreloadMetaData(assetMetaPath, comp, comp.AssetTypeDefinition);
                            await metaData.SaveToFile();
                            _metaData.Add(relativePath, metaData);
                        }
                    }
                    else
                    {
                        var metaData = new PreloadMetaData(assetMetaPath);
                        await metaData.LoadFromFile();
                        metaData.IsFavorite = _config.IsFavorite(PathTools.ToRelativePath(assetMetaPath.Path));
                        _metaData.Add(relativePath, metaData);
                    }
                }
            });

            sw.Stop();
            _logger.Info($"Loaded Metadata in {sw.Elapsed.Seconds}.{sw.Elapsed.Milliseconds}s");
        }
Ejemplo n.º 2
0
        private async Task LoadMetaData(string pieceRelativePath)
        {
            var assetMetaPath = new AssetMetaPath(new FileInfo(PathTools.ToFullPath(pieceRelativePath)));

            if (_metaData.TryGetValue(assetMetaPath.RelativeMetaDataPath, out _))
            {
                return;
            }
            if (!File.Exists(assetMetaPath.MetaDataPath))
            {
                return;
            }

            var metaData = new PreloadMetaData(assetMetaPath);

            metaData.IsFavorite = _config.IsFavorite(assetMetaPath.RelativePath);
            await metaData.LoadFromFile();

            _metaData.Add(assetMetaPath.RelativeMetaDataPath, metaData);
        }
Ejemplo n.º 3
0
        private void LoadMetaData(string pieceRelativePath)
        {
            var assetMetaPath = new AssetMetaPath(new FileInfo(PathTools.ToFullPath(pieceRelativePath)), _pluginDirs.Cache.GetFile(Path.GetFileName(pieceRelativePath) + ".meta").FullName);

            if (_metaData.TryGetValue(assetMetaPath.RelativePath + ".meta", out _))
            {
                return;
            }

            if (!File.Exists(assetMetaPath.MetaDataPath))
            {
                return;
            }

            var metaData = new PreloadMetaData(assetMetaPath);

            metaData.IsFavorite = _config.IsFavorite(assetMetaPath.RelativePath);
            metaData.LoadFromFile();
            _metaData.Add(assetMetaPath.RelativePath + ".meta", metaData);
        }
Ejemplo n.º 4
0
        private async Task LoadAllMetaDataForLoader(AssetBundleLoader loader, bool createIfNotExisting = false)
        {
            var sw = DebugTimer.StartNew("Loading Metadata");

            foreach (var assetMetaPath in loader.CollectFiles(_pluginDirs))
            {
                if (_metaData.TryGetValue(assetMetaPath.RelativePath + ".meta", out _))
                {
                    continue;
                }

                if (!assetMetaPath.HasMetaData)
                {
                    if (createIfNotExisting)
                    {
                        var comp = await this[PathTools.ToRelativePath(assetMetaPath.Path)];

                        if (comp == null)
                        {
                            continue;
                        }

                        var metaData = new PreloadMetaData(assetMetaPath, comp, comp.AssetTypeDefinition);
                        metaData.SaveToFile();
                        _metaData.Add(assetMetaPath.RelativePath + ".meta", metaData);
                    }
                }
                else
                {
                    var metaData = new PreloadMetaData(assetMetaPath);
                    metaData.LoadFromFile();
                    metaData.IsFavorite = _config.IsFavorite(PathTools.ToRelativePath(assetMetaPath.Path));
                    _metaData.Add(assetMetaPath.RelativePath + ".meta", metaData);
                }
            }

            sw.Print(_logger);
        }