public static DirectoryCopy ( string sourceDirName, string destDirName, bool copySubDirs ) : bool | ||
sourceDirName | string | |
destDirName | string | |
copySubDirs | bool | |
Результат | bool |
public static bool CopySoundbanks(bool generate, string platformName, ref string destinationFolder) { if (string.IsNullOrEmpty(platformName)) { UnityEngine.Debug.LogErrorFormat("WwiseUnity: Could not determine platform name for <{0}> platform", platformName); return(false); } if (generate) { var platforms = new System.Collections.Generic.List <string> { platformName }; AkUtilities.GenerateSoundbanks(platforms); } string sourceFolder; if (!AkBasePathGetter.GetSoundBankPaths(platformName, out sourceFolder, out destinationFolder)) { return(false); } if (!AkUtilities.DirectoryCopy(sourceFolder, destinationFolder, true)) { destinationFolder = null; UnityEngine.Debug.LogErrorFormat("WwiseUnity: Could not copy SoundBank folder for <{0}> platform", platformName); return(false); } UnityEngine.Debug.LogFormat("WwiseUnity: Copied SoundBank folder to streaming assets folder <{0}> for <{1}> platform build", destinationFolder, platformName); return(true); }
static void GenericBuild(string[] scenes, string targetDir, string appName, BuildTarget buildTarget, BuildOptions buildOptions) { string res = BuildPipeline.BuildPlayer(scenes, targetDir + "/" + appName + ".exe", buildTarget, buildOptions); if (res.Length > 0) { throw new Exception("BuildPlayer failure: " + res); } else { // Copy WWise soundbanks string wwiseProjFile = Path.Combine(Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath).Replace('/', '\\'); string wwiseProjectFolder = wwiseProjFile.Remove(wwiseProjFile.LastIndexOf(Path.DirectorySeparatorChar)); string wwisePlatformString = UnityToWwisePlatformString(EditorUserBuildSettings.activeBuildTarget.ToString()); string sourceSoundBankFolder = Path.Combine(wwiseProjectFolder, AkBasePathGetter.GetPlatformBasePath()); string destinationSoundBankFolder = Path.Combine(targetDir + "/" + appName + "_Data/StreamingAssets", Path.Combine(WwiseSetupWizard.Settings.SoundbankPath, wwisePlatformString) ); if (!AkUtilities.DirectoryCopy(sourceSoundBankFolder, destinationSoundBankFolder, true)) { Debug.LogError("WwiseUnity: The soundbank folder for the " + wwisePlatformString + " platform doesn't exist. Make sure it was generated in your Wwise project"); throw new Exception("BuildPlayer failure: " + res); } Directory.GetFiles(targetDir + "/" + appName + "_Data/StreamingAssets", "*.meta", SearchOption.AllDirectories).ForEach(file => File.Delete(file)); } }
// Based on AkExampleAppBuilderBase.Build private static void MoveSoundBanks(string wwisePlatformString) { string wwiseProjFile = Path.Combine(Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath).Replace('/', Path.DirectorySeparatorChar); string wwiseProjectFolder = wwiseProjFile.Remove(wwiseProjFile.LastIndexOf(Path.DirectorySeparatorChar)); string sourceSoundBankFolder = Path.Combine(wwiseProjectFolder, AkBasePathGetter.GetPlatformBasePath()); string destinationSoundBankFolder = Path.Combine(Application.dataPath + Path.DirectorySeparatorChar + "StreamingAssets", Path.Combine(WwiseSetupWizard.Settings.SoundbankPath, wwisePlatformString)); Debug.Log("Copying soundbanks from: " + sourceSoundBankFolder + "\nto: " + destinationSoundBankFolder); if (!AkUtilities.DirectoryCopy(sourceSoundBankFolder, destinationSoundBankFolder, true)) { Debug.LogError("WwiseUnity: The soundbank folder for the " + wwisePlatformString + " platform doesn't exist. Make sure it was generated in your Wwise project"); } UnityEditor.AssetDatabase.Refresh(); }
public static bool CopySoundbanks(bool generate, string platformName, ref string destinationFolder) { if (string.IsNullOrEmpty(platformName)) { UnityEngine.Debug.LogError("WwiseUnity: Could not determine platform name for <" + platformName + "> platform"); } else { if (generate) { var platforms = new System.Collections.Generic.List <string> { platformName }; AkUtilities.GenerateSoundbanks(platforms); } var sourceFolder = AkBasePathGetter.GetPlatformBasePathEditor(platformName); if (string.IsNullOrEmpty(sourceFolder)) { UnityEngine.Debug.LogError("WwiseUnity: Could not find source folder for <" + platformName + "> platform. Did you remember to generate your banks?"); } else if (!SetDestinationPath(platformName, ref destinationFolder)) { UnityEngine.Debug.LogError("WwiseUnity: Could not find destination folder for <" + platformName + "> platform"); } else if (!AkUtilities.DirectoryCopy(sourceFolder, destinationFolder, true)) { destinationFolder = null; UnityEngine.Debug.LogError("WwiseUnity: Could not copy soundbank folder for <" + platformName + "> platform"); } else { UnityEngine.Debug.Log("WwiseUnity: Copied soundbank folder to streaming assets folder <" + destinationFolder + "> for <" + platformName + "> platform build"); return(true); } } return(false); }
public static bool Build() { //Choose app name and location string appPath = EditorUtility.SaveFilePanel("Build Unity-Wwise project", //window title Application.dataPath.Remove(Application.dataPath.LastIndexOf('/')), //Default app location (unity project root directory) "Unity_Wwise_app", //Default app name getPlatFormExtension() //app extension (depends on target platform) ); //check if the build was cancelled bool isUserCancelledBuild = appPath == ""; if (isUserCancelledBuild) { UnityEngine.Debug.Log("WwiseUnity: User cancelled the build."); return(false); } //get Wwise project file (.wproj) path string wwiseProjFile = Path.Combine(Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath).Replace('/', '\\'); //get Wwise project root folder path string wwiseProjectFolder = wwiseProjFile.Remove(wwiseProjFile.LastIndexOf(Path.DirectorySeparatorChar)); //get Wwise platform string (the string isn't the same as unity for some platforms) string wwisePlatformString = UnityToWwisePlatformString(EditorUserBuildSettings.activeBuildTarget.ToString()); //get soundbank location in the Wwise project for the current platform target string sourceSoundBankFolder = Path.Combine(wwiseProjectFolder, AkBasePathGetter.GetPlatformBasePath()); //get soundbank destination in the Unity project for the current platform target string destinationSoundBankFolder = Path.Combine(Application.dataPath + "\\StreamingAssets", //Soundbank must be inside the StreamingAssets folder Path.Combine(WwiseSetupWizard.Settings.SoundbankPath, wwisePlatformString) ); //Copy the soundbank from the Wwise project to the unity project (Inside the StreamingAssets folder as defined in Window->Wwise Settings) if (!AkUtilities.DirectoryCopy(sourceSoundBankFolder, //source folder destinationSoundBankFolder, //destination true //copy subfolders ) ) { UnityEngine.Debug.LogError("WwiseUnity: The soundbank folder for the " + wwisePlatformString + " platform doesn't exist. Make sure it was generated in your Wwise project"); return(false); } //Get all the scenes to build as defined in File->Build Settings string[] scenes = new string[EditorBuildSettings.scenes.Length]; for (int i = 0; i < EditorBuildSettings.scenes.Length; i++) { scenes[i] = EditorBuildSettings.scenes[i].path; } //Build the app BuildPipeline.BuildPlayer(scenes, //scenes to build appPath, //Location of the app to create EditorUserBuildSettings.activeBuildTarget, //Platform for which to build the app BuildOptions.None ); //Delete the soundbank from the unity project so they dont get copied in the game folder of fututre builds Directory.Delete(destinationSoundBankFolder, true); return(true); }