public override BuildResult Run(BuildContext context) { var info = new ProviderInfo(); var classicSharedData = context.GetValue <ClassicSharedData>(); var oldStreamingAssetsDirectory = classicSharedData.StreamingAssetsDirectory; classicSharedData.StreamingAssetsDirectory = "Assets/StreamingAssets"; foreach (var customizer in classicSharedData.Customizers) { customizer.RegisterAdditionalFilesToDeploy((from, to) => { var toNPath = new NPath(to).MakeAbsolute(); new NPath(from).MakeAbsolute().Copy(toNPath.EnsureParentDirectoryExists()); info.Paths.Add(toNPath); }); } classicSharedData.StreamingAssetsDirectory = oldStreamingAssetsDirectory; context.SetValue(info); return(context.Success()); }
internal static void InstallStreamingAssets(string stagingAreaDataPath, string streamingAssetsFolderName, BuildReport report) { if (Directory.Exists(StreamingAssets)) { var outputPath = Path.Combine(stagingAreaDataPath, streamingAssetsFolderName); FileUtil.CopyDirectoryRecursiveForPostprocess(StreamingAssets, outputPath, true); report?.RecordFilesAddedRecursive(outputPath, CommonRoles.streamingAsset); } foreach (var(dst, src) in BuildPlayerContext.ActiveInstance.StreamingAssets) { NPath targetPlayerPath = $"{stagingAreaDataPath}/{streamingAssetsFolderName}/{dst}"; if (targetPlayerPath.Exists()) { var errorMessage = "error: Callback provided streaming assets file conflicts with file already present in project." + $" Project file 'StreamingAssets/{dst}'. Callback provided file '{src}'."; Debug.LogError(errorMessage); throw new BuildFailedException(errorMessage); } FileUtil.UnityFileCopy(src.ToString(), targetPlayerPath.EnsureParentDirectoryExists().ToString()); report?.RecordFileAdded(targetPlayerPath.ToString(SlashMode.Native), CommonRoles.streamingAsset); } }