static void UninstallIntegration() { try { // Close the Picker window AkWwisePicker window = EditorWindow.GetWindow <AkWwisePicker>("AkWwisePicker", true, typeof(EditorWindow).Assembly.GetType("UnityEditor.ConsoleWindow")); window.Close(); // Remove the WwiseGlobal object AkInitializer[] AkInitializers = FindObjectsOfType(typeof(AkInitializer)) as AkInitializer[]; if (AkInitializers.Length > 0) { GameObject.DestroyImmediate(AkInitializers[0].gameObject); } // Remove the AkAudioListener component from the camera AkAudioListener listener = Camera.main.gameObject.GetComponent <AkAudioListener>(); if (listener != null) { Component.DestroyImmediate(listener); } // Put back the built-in Audio Listener if (Camera.main.gameObject.GetComponent <AkAudioListener>() == null) { Camera.main.gameObject.AddComponent <AudioListener>(); } // Remove the plugins string pluginsDir = Path.Combine(Application.dataPath, "Plugins"); if (Directory.Exists(pluginsDir)) { string[] foundBundles = Directory.GetDirectories(pluginsDir, "AkSoundEngine*.bundle"); foreach (string bundle in foundBundles) { Directory.Delete(bundle, true); } string[] foundPlugins = Directory.GetFiles(pluginsDir, "AkSoundEngine*", SearchOption.AllDirectories); foreach (string plugin in foundPlugins) { File.Delete(plugin); } } // Remove the wwise settings xml file if (File.Exists(Path.Combine(Application.dataPath, WwiseSettings.WwiseSettingsFilename))) { File.Delete(Path.Combine(Application.dataPath, WwiseSettings.WwiseSettingsFilename)); } // Delete the Wwise folder within the Assets folder if (Directory.Exists(Path.Combine(Application.dataPath, "Wwise"))) { Directory.Delete(Path.Combine(Application.dataPath, "Wwise"), true); if (File.Exists(Path.Combine(Application.dataPath, "Wwise.meta"))) { File.Delete(Path.Combine(Application.dataPath, "Wwise.meta")); } } // Remove the generated SoundBanks string sbPath = AkUtilities.GetFullPath(Application.streamingAssetsPath, Settings.SoundbankPath); if (Directory.Exists(sbPath)) { Directory.Delete(sbPath, true); } // Delete the Mac documentation string docPath = Path.Combine(Path.Combine(Application.dataPath, ".."), "WwiseUnityIntegrationHelp_AppleCommon_en"); if (Directory.Exists(docPath)) { Directory.Delete(docPath, true); } // Re-activate built-in audio AkUnitySettingsParser.SetBoolValue("m_DisableAudio", false, "AudioManager"); AssetDatabase.Refresh(); } catch (Exception e) { Debug.Log(e.ToString()); } }
// Perform all necessary steps to use the Wwise Unity integration. bool Setup() { bool NoErrorHappened = true; // 0. Make sure the soundbank directory exists string sbPath = AkUtilities.GetFullPath(Application.streamingAssetsPath, Settings.SoundbankPath); if (!Directory.Exists(sbPath)) { Directory.CreateDirectory(sbPath); } #if !UNITY_5 // 1. Disable built-in audio if (!AkUnitySettingsParser.SetBoolValue("m_DisableAudio", true, "AudioManager")) { EditorUtility.DisplayDialog("Warning", "The Audio settings file format has changed. Please disable built-in audio by going to Project->Project Settings->Audio, and check \"Disable Audio\".", "Ok"); } #endif // 2. Create a "WwiseGlobal" game object and set the AkSoundEngineInitializer and terminator scripts // 3. Set the SoundBank path property on AkSoundEngineInitializer if (!Settings.OldProject) { CreateWwiseGlobalObject(); } // 4. Set the script order of AkInitializer, AkTerminator, AkGameObj, AkBankLoad (before default time), AkAudioListener by changing the .meta file if (!SetAllScriptExecutionOrder()) { EditorUtility.DisplayDialog("Error", "Could not change script exec order!", "Ok"); NoErrorHappened = false; } // 5. Add AkAudioListener component to camera if (!Settings.OldProject) { SetListener(); } // 6. Enable "Run In Background" in PlayerSettings (PlayerSettings.runInbackground property) PlayerSettings.runInBackground = true; #if !UNITY_5 // 7. Install the Profile libraries of the installed platforms. This should actually be a change in the way we build unitypackages. if (!InstallAllPlatformProfilePlugins()) { EditorUtility.DisplayDialog("Error", "Could not install some platform plugins!", "Ok"); NoErrorHappened = false; } #endif // 8. Verify DirectX is installed (windows only) #if UNITY_EDITOR_WIN Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\DirectX\\"); if (key == null) { EditorUtility.DisplayDialog("Warning", "Detected the DirectX End-User Runtime is not installed. You might have issues using the Windows version of the plugin", "Ok"); } #endif // 9. Activate WwiseIDs file generation, and point Wwise to the Assets/Wwise folder // 10. Change the SoundBanks options so it adds Max Radius information in the Wwise project if (!SetSoundbankSettings()) { EditorUtility.DisplayDialog("Warning", "Could not modify Wwise Project to generate the header file!", "Ok"); } // 11. Generate the WwiseIDs.cs file from the .h file // GenerateWwiseIDsCsFile(); // 12. Refresh UI/Settings files. Repaint(); // 13. Make sure the installed SDK matches the one that was build on the machine ValidateVersion(); // 14. Move some files out of the assets folder // todo. // 15. Populate the picker AkWwiseProjectInfo.GetData(); // Load data if (!String.IsNullOrEmpty(Settings.WwiseProjectPath)) { AkWwiseProjectInfo.Populate(); AkWwisePicker.PopulateTreeview(); if (AkWwiseProjectInfo.GetData().autoPopulateEnabled) { AkWwiseWWUWatcher.GetInstance().SetPath(Path.GetDirectoryName(AkUtilities.GetFullPath(Application.dataPath, WwiseSettings.LoadSettings().WwiseProjectPath))); AkWwiseWWUWatcher.GetInstance().StartWWUWatcher(); } } return(NoErrorHappened); }