Example #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");
        }
Example #2
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);
        }
Example #3
0
        public async Task <ModelComposition> CreateMetaData(AssetMetaPath assetMetaPath)
        {
            var relativePath = PathTools.ToRelativePath(assetMetaPath.MetaDataPath);

            if (_metaData.TryGetValue(relativePath, out _))
            {
                return(null);
            }

            var comp = await await UnityMainThreadTaskScheduler.Factory.StartNew(() => this[PathTools.ToRelativePath(assetMetaPath.Path)]);

            if (comp == null)
            {
                return(null);
            }

            var metaData = new PreloadMetaData(assetMetaPath, comp, comp.AssetTypeDefinition);
            await metaData.SaveToFile();

            _metaData.Add(relativePath, metaData);

            return(comp);
        }
Example #4
0
        internal async Task <ModelComposition> CreateMetaData(AssetMetaPath assetMetaPath)
        {
            var relativePath = assetMetaPath.RelativePath + ".meta";

            if (_metaData.TryGetValue(relativePath, out _))
            {
                return(null);
            }

            var comp = await this[PathTools.ToRelativePath(assetMetaPath.Path)];

            if (comp == null)
            {
                return(null);
            }

            var metaData = new PreloadMetaData(assetMetaPath, comp, comp.AssetTypeDefinition);

            metaData.SaveToFile();
            _metaData.Add(relativePath, metaData);

            return(comp);
        }