Beispiel #1
0
        private void RecurseStreamingAssetsDirectory(string path, ManifestEntry newEntry)
        {
            var di = new DirectoryInfo(path);

            // foreach (var fi in di.EnumerateFiles())
            di.EnumerateFiles()
            .ToList().ForEach(
                //.AsParallel().ForAll(
                fi =>
            {
                var validExtensions = new List <string>(new[] { ".json", ".csv" });
                var fileName        = fi.Name;
                var fileData        = validExtensions.Contains(fi.Extension) ? File.ReadAllText(fi.FullName) : null;
                var hostDirectory   = di.Name;

                var retVal = StreamingAssetProcessor.ProcessFile(
                    newEntry,
                    di,
                    fi.FullName,
                    fileData,
                    hostDirectory,
                    this.referenceFinderService,
                    this.logger);

                if (retVal != null)
                {
                    if (retVal is IObjectDefinition obj)
                    {
                        newEntry.Objects.Add(obj);

                        if (retVal is AssetBundleObjectDefinition assetBundleObjectDefinition)
                        {
                            var stubJsonObject         = JsonConvert.DeserializeObject($"{{\"AssetBundleName\": \"{assetBundleObjectDefinition.Id}\"}}");
                            var prefabObjectDefinition = ObjectDefinitionFactory.ObjectDefinitionFactorySingleton.Get(
                                ObjectType.Prefab,
                                new ObjectDefinitionDescription(null, null, null, null, (JObject)stubJsonObject),
                                (JObject)stubJsonObject,
                                Path.Combine(path, assetBundleObjectDefinition.Name),
                                referenceFinderService);
                            newEntry.Objects.Add(prefabObjectDefinition);
                        }
                    }
                    else if (retVal is IResourceDefinition res)
                    {
                        newEntry.Resources.Add(res);
                    }
                    else
                    {
                        throw new InvalidProgramException($"Unknown streaming asset object.");
                    }
                }
            });

            di.GetDirectories()
            .ToList().ForEach(
                //.AsParallel().ForAll(
                subdi => this.RecurseStreamingAssetsDirectory(subdi.FullName, newEntry));
        }
        private void RecurseStreamingAssetsDirectory(string path, ManifestEntry newEntry)
        {
            var di = new DirectoryInfo(path);

            foreach (var fi in di.EnumerateFiles())
            {
                var fileName      = fi.Name;
                var fileData      = File.ReadAllText(fi.FullName);
                var hostDirectory = di.Name;

                var retVal = StreamingAssetProcessor.ProcessFile(
                    newEntry,
                    di,
                    fi.FullName,
                    fileData,
                    hostDirectory,
                    this.referenceFinderService);

                if (retVal != null)
                {
                    if (retVal is IObjectDefinition obj)
                    {
                        newEntry.Objects.Add(obj);
                    }
                    else if (retVal is IResourceDefinition res)
                    {
                        newEntry.Resources.Add(res);
                    }
                    else
                    {
                        throw new InvalidProgramException($"Unknown streaming asset object.");
                    }
                }
            }

            di
            .GetDirectories()
            //.ToList().ForEach(
            .AsParallel().ForAll(
                subdi => this.RecurseStreamingAssetsDirectory(subdi.FullName, newEntry));
        }