Pre-export method delete directory

In our ‘StreamingAssets’ directory we have 2 sub directories. One for mp4 movie files and one for ogv.
Depending on the build target I would like to call a pre-export method to delete the mp4 or ogv directory.
How can I do this?

public static void RemoveMp4Videos()
{
//TODO: Remove mp4 directory from StreamingAssets
}
public static void RemoveOgvVideos()
{
//TODO: Remove ogv directory from StreamingAssets
}

You can specify a pre-export method to run in the advanced settings for a target created in Cloud Build. See the advanced settings guide.

That’s what I already understand. But how do I delete a subdirectory from the StreamingAssets?

You can use DeleteFileOrDirectory from the FileUtil class and refresh the database:

FileUtil.DeleteFileOrDirectory("Assets/Streaming Assets/MyFolder");
AssetDatabase.Refresh();

Put this in a public static method and use the fully ualified name of the method in the Pre-Export Method Name field, e.g. “BuildScript.RemoveMp4Videos”.

1 Like

Thanks, I will try this!