Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

Unity player build error with UnauthorizedAccessException:

0 votes
When making a standalone player build in Unity for our windows project, after building once and doing a second build, I get the following:

UnauthorizedAccessException: Access to the path "D:\myCoolProject\Assets\StreamingAssets\Audio\GeneratedSoundBanks\Windows\Init.bnk" is denied.

I assume that these files are copied from the wwise project folder and they are indeed read only because they are checked into perforce.  I know why the files need to get copied, but they problem is if they exist there already from a previous build (and are marked read only as they are because they were copied from the wwiseProject folder to the StreamingAssets folder with the read only attribute set because they are checked into perforce).  Does wwise not handle this particular situation?
asked May 8, 2018 in General Discussion by Mark A. (130 points)

1 Answer

+3 votes
 
Best answer

We experienced the exact same issue and resolved it by changing 2 files:
In AkUtitlies around line 590:

var files = dir.GetFiles();
foreach (var file in files)
{
            var temppath = System.IO.Path.Combine(destDirName, file.Name);
            //Edit by Shanghai Vancouver Film School Game Design

            System.IO.FileInfo fileInfo = new System.IO.FileInfo(temppath);
            if (fileInfo.Exists)
                fileInfo.IsReadOnly = false;

            System.IO.FileInfo secondFileInfo = file.CopyTo(temppath, true);
            secondFileInfo.IsReadOnly = false;
}

And AkBuildPreprocessor around line 129:

//Edit by Shanghai Vancouver Film School Game Design
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(destinationFolder);

if (dirInfo.Exists)
{
      foreach (System.IO.FileInfo f in dirInfo.GetFiles())
      {
            f.IsReadOnly = false;
      }
}
System.IO.Directory.Delete(destinationFolder, true);
UnityEngine.Debug.Log("WwiseUnity: Deleting streaming assets folder <" + destinationFolder + ">");
 

Hope it helps!

answered Jul 11, 2018 by SHVFS G. (500 points)
selected Jul 12, 2018 by Mark A.
Thanks.  Was pleased to see this.  It didn't occur to me at the time to look in the cs code to fix this, but this is a good idea.  I wound up solving this myself by marking the wwise files as +w so they were always writable
thanks a lot for this answer! You saved me so much time!
Thank you so much! You are a god send.
...