SirNmad

WwiseFix - ShareViolation CopyBanks

Oct 18th, 2019
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.63 KB | None | 0 0
  1. // Add this new method to AkBuildPreProcessor.cs
  2. static bool AreSourceAndDestinationEqualAndValid(string platformName)
  3.     {        
  4.         string sourceFolder = AkBasePathGetter.GetPlatformBasePathEditor(platformName);
  5.         string destinationFolder = string.Empty;
  6.  
  7.         SetDestinationPath(platformName, ref destinationFolder);
  8.  
  9.         if (!string.IsNullOrEmpty(sourceFolder) && !string.IsNullOrEmpty(destinationFolder))
  10.         {
  11.             var sourcePathInfo = new System.IO.DirectoryInfo(sourceFolder);
  12.             var destinationPathInfo = new System.IO.DirectoryInfo(destinationFolder);
  13.  
  14.             if (sourcePathInfo.Parent.FullName == destinationPathInfo.Parent.FullName && sourcePathInfo.Name == destinationPathInfo.Name)
  15.             {
  16.                 return true;                
  17.             }
  18.         }
  19.         return false;
  20.     }
  21.  
  22. // REPLACE AkBuildPreProcessor.CopySoundBanks with this method
  23. public static bool CopySoundbanks(bool generate, string platformName, ref string destinationFolder)
  24.     {
  25.         if (string.IsNullOrEmpty(platformName))
  26.             UnityEngine.Debug.LogError("WwiseUnity: Could not determine platform name for <" + platformName + "> platform");
  27.         else
  28.         {
  29.             if (generate)
  30.             {
  31.                 var platforms = new System.Collections.Generic.List<string> { platformName };
  32.                 AkUtilities.GenerateSoundbanks(platforms);
  33.             }
  34.  
  35.             string sourceFolder = AkBasePathGetter.GetPlatformBasePathEditor(platformName);
  36.             if (string.IsNullOrEmpty(sourceFolder))
  37.             {
  38.                 UnityEngine.Debug.LogError("WwiseUnity: Could not find source folder for <" + platformName +
  39.                                            "> platform. Did you remember to generate your banks?");
  40.             }
  41.             else if (!SetDestinationPath(platformName, ref destinationFolder))
  42.             {
  43.                 UnityEngine.Debug.LogError("WwiseUnity: Could not find destination folder for <" + platformName + "> platform");
  44.             }
  45.             else if ((generate && AreSourceAndDestinationEqualAndValid(platformName)) || AkUtilities.DirectoryCopy(sourceFolder, destinationFolder, true))
  46.             {
  47.                 UnityEngine.Debug.Log("WwiseUnity: Copied soundbank folder to streaming assets folder <" + destinationFolder +
  48.                                       "> for <" + platformName + "> platform build");
  49.                 return true;
  50.             }
  51.             else
  52.             {
  53.                 destinationFolder = null;
  54.                 UnityEngine.Debug.LogError("WwiseUnity: Could not copy soundbank folder for <" + platformName + "> platform");
  55.             }
  56.         }
  57.  
  58.         return false;
  59.     }
Add Comment
Please, Sign In to add comment