For standalone builds, MovieTextures work great, but on many other platforms, movies must be placed in StreamingAssets for use with platform-specific movie playing APIs. To avoid including the movie files when building for standalone, is it possible to exclude the StreamingAssets folder?
Workarounds, such as a post-build hook that deletes the StreamingAssets folder from the standalone build, are also welcome.
For anyone who comes across this, here is the script I ended up writing to delete the StreamingAssets folder from a standalone build:
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.Collections;
using System.IO;
public static class DeleteBuildStreamingAssetsIfUnnecessary {
[PostProcessBuild(100)]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
string streamingAssetsPath = null;
switch (target) {
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneWindows64:
case BuildTarget.StandaloneLinux:
case BuildTarget.StandaloneLinux64:
case BuildTarget.StandaloneLinuxUniversal:
{
// windows and linux use "_Data" folder
string root = Path.Combine(Path.GetDirectoryName(pathToBuiltProject),Path.GetFileNameWithoutExtension(pathToBuiltProject)+"_Data");
streamingAssetsPath = Path.Combine(root,"StreamingAssets");
}
break;
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneOSXIntel64:
case BuildTarget.StandaloneOSXUniversal:
{
streamingAssetsPath = Path.Combine(pathToBuiltProject, "Contents");
streamingAssetsPath = Path.Combine(streamingAssetsPath, "Resources");
streamingAssetsPath = Path.Combine(streamingAssetsPath, "Data");
streamingAssetsPath = Path.Combine(streamingAssetsPath, "StreamingAssets");
}
break;
}
if (streamingAssetsPath == null || !Directory.Exists(streamingAssetsPath))
return;
Directory.Delete(streamingAssetsPath, true);
}
}
Thank you for your code, @zach-r-d 
Here is my adaptation that strips files from the StreamingAssets folder based on the target platform:
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.Android;
using System.IO;
using UnityEngine;
// Exclude streaming assets for other platforms from build output
public class StripStreamingAssets : IPostprocessBuildWithReport, IPostGenerateGradleAndroidProject
{
public int callbackOrder => 0;
public void OnPostprocessBuild(BuildReport report)
{
string buildPath = Path.GetDirectoryName(report.summary.outputPath);
if (report.summary.platform == BuildTarget.StandaloneWindows64)
{
string streamingAssetsPath = Path.Combine(buildPath, "Cynteract_Data", "StreamingAssets");
StripFiles(BuildTarget.StandaloneWindows64, streamingAssetsPath);
}
}
public void OnPostGenerateGradleAndroidProject(string path)
{
// path points to the root of the exported Gradle project
string streamingAssetsPath = Path.Combine(path, "src", "main", "assets");
StripFiles(BuildTarget.Android, streamingAssetsPath);
}
private void StripFiles(BuildTarget target, string streamingAssetsPath)
{
Debug.Log($"Stripping files for target: {target} at path: {streamingAssetsPath}");
if (!Directory.Exists(streamingAssetsPath))
return;
var foldersToDelete = new System.Collections.Generic.List<string>();
var filesToDelete = new System.Collections.Generic.List<string>();
switch (target)
{
case BuildTarget.Android:
foldersToDelete.Add(Path.Combine(streamingAssetsPath, "Windows"));
filesToDelete.Add(Path.Combine(streamingAssetsPath, "esptool.exe"));
foreach (var file in Directory.GetFiles(streamingAssetsPath, "Connector*.exe"))
{
filesToDelete.Add(file);
}
break;
case BuildTarget.StandaloneWindows64:
foldersToDelete.Add(Path.Combine(streamingAssetsPath, "Android"));
break;
}
foreach (var folder in foldersToDelete)
{
Directory.Delete(folder, true);
}
foreach (var file in filesToDelete)
{
File.Delete(file);
}
}
}