All .bytes files being deleted and banks being copied repeatedly when Import Type is set to AssetBundles

I’ve just updated from FMOD 1.x to 2.00.03 and I’m seeing some fairly serious issues when the import mode is set to Asset Bundles.

  • The FMOD banks are being deleted then copied into the Assets folder repeatedly every few seconds.
  • All files that end in .bytes in the project are being deleted

This is due to faulty logic in EventManager.CopyToStreamingAssets.

This line is incorrect as it assumes that the files will be in streaming assets.
var targetShortName = RuntimeUtils.GetCommonPlatformPath(bankFileName).Replace(RuntimeUtils.GetCommonPlatformPath(Application.streamingAssetsPath + '/'), "");

Instead something like this might be better:
var targetShortName = RuntimeUtils.GetCommonPlatformPath(bankFileName).Replace(RuntimeUtils.GetCommonPlatformPath(bankTargetFolder), "");

But more fundamentally, the principle of searching for any .bytes files and deleting them if they don’t match the name of a bank seems entirely flawed. I get why that might make sense for a .banks file but it certainly doesn’t for a .bytes file that may contain any binary data used in the project.

This issue was exacerbated in this release by the addition of SearchOption.AllDirectories to this line:

string[] currentBankFiles = Directory.GetFiles(bankTargetFolder, "*." + bankTargetExension, SearchOption.AllDirectories);

This wasn’t there in 1.x which meant that at worst it would delete .bytes files in the Assets folder but not in any child directories.

All in all this approach seems dangerous and a bit lazy!

I’d be great to have a response to this!

Thanks for the feedback, we will look into this for the upcoming release.

Hi there, I’m having the same issue with FMOD 2.00.03. The big issue with that is that I cannot use the AssetBundle mode at all.

I would like to add that in this method, the line :

if (!eventCache.EditorBanks.Exists((x) => targetShortName == x.Name + “.” + BankExtension))

isn’t correct as BankExtension is a static string equal to “bank”. Instead it should use the bankTargetExension string generated just a few lines above that will hold either “bytes” or “bank” depending on the context.

In the end, I successfully fixed the issue by using this piece of code :

//Code …

string targetShortName = RuntimeUtils.GetCommonPlatformPath(bankFileName);
targetShortName = Path.GetFileName(targetShortName);
if (!eventCache.EditorBanks.Exists((x) => targetShortName == x.Name + “.” + bankTargetExension))

Hope it helps and hopefully we’ll get a fix soon.

Actually it seems it has been fixed in 2.00.04. It’s working alright now.

@cameron-fmod I’m still having this issue with fmod 2.00.04. All the .bytes files in the project are being deleted continuously.

Are you able to share the log from Unity?

Hi @cameron-fmod

I’m afraid I can’t right now as I’ve worked around it by setting a TargetAssetPath folder for the FMOD files. The issue only occurs if the TargetAssetPath is empty (the default) or if it’s set to a folder with other .bytes files in it.

The code that does this is in EventManager.CopyToStreamingAssets. I’ve commented out the “Clean out any stale .bank files” block as well, to be safe.

The crux of the issue is that the “Clean out any stale .bank files” doesn’t do what it says it does. If the project is using asset bundles, it goes and deletes any “.bytes” files that are in the TargetAssetFolder. If that TargetAssetFolder is not set, then that deletes any .bytes files in the project. .bytes files are a standard Unity file extension for binary data, so this doesn’t feel like it’s ever a safe thing to do - especially if the TargetAssetFolder isn’t set. You should have a better way to identify assets that belong to FMOD in this situation - either special filenames or perhaps Unity asset tags.

That is a valid point, I have raised this a task to investigate further.