public static LoadSettings ( bool ForceLoad = false ) : WwiseSettings, | ||
ForceLoad | bool | |
return | WwiseSettings, |
// Disable the built-in audio listener, and add the AkGameObj to the camera private static void SetListener() { WwiseSettings settings = WwiseSettings.LoadSettings(); // Remove the audio listener script if (settings.CreateWwiseListener && Camera.main != null) { AudioListener listener = Camera.main.gameObject.GetComponent <AudioListener>(); if (listener != null) { Component.DestroyImmediate(listener); } // Add the AkGameObj script { Camera.main.gameObject.AddComponent <AkAudioListener>(); AkGameObj akGameObj = Camera.main.gameObject.GetComponent <AkGameObj>(); akGameObj.isEnvironmentAware = false; } } }
// Disable the built-in audio listener, and add the AkGameObj to the camera private static void SetListener() { var settings = WwiseSettings.LoadSettings(); // Remove the audio listener script if (settings.CreateWwiseListener && UnityEngine.Camera.main != null) { var listener = UnityEngine.Camera.main.gameObject.GetComponent <UnityEngine.AudioListener>(); if (listener != null) { UnityEngine.Object.DestroyImmediate(listener); } // Add the AkGameObj script { UnityEngine.Camera.main.gameObject.AddComponent <AkAudioListener>(); var akGameObj = UnityEngine.Camera.main.gameObject.GetComponent <AkGameObj>(); akGameObj.isEnvironmentAware = false; } } }
private static void PostImportFunction() { UnityEditor.EditorApplication.hierarchyWindowChanged += CheckWwiseGlobalExistance; UnityEditor.EditorApplication.delayCall += CheckPicker; if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || UnityEditor.EditorApplication.isCompiling) { return; } try { if (System.IO.File.Exists(UnityEngine.Application.dataPath + System.IO.Path.DirectorySeparatorChar + WwiseSettings.WwiseSettingsFilename)) { WwiseSetupWizard.Settings = WwiseSettings.LoadSettings(); AkWwiseProjectInfo.GetData(); } if (!string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath)) { AkWwisePicker.PopulateTreeview(); if (AkWwiseProjectInfo.GetData().autoPopulateEnabled) { AkWwiseWWUBuilder.StartWWUWatcher(); } } } catch (System.Exception e) { UnityEngine.Debug.Log(e.ToString()); } //Check if a WwiseGlobal object exists in the current scene CheckWwiseGlobalExistance(); }
public static void Populate() { try { if (EditorApplication.isPlaying) { return; } if (WwiseSetupWizard.Settings.WwiseProjectPath == null) { WwiseSettings.LoadSettings(); } if (String.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath)) { Debug.LogError("Wwise project needed to populate from Work Units. Aborting."); return; } s_wwiseProjectPath = Path.GetDirectoryName(AkUtilities.GetFullPath(Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath)); if (!Directory.Exists(s_wwiseProjectPath)) { AkWwisePicker.WwiseProjectFound = false; return; } else { AkWwisePicker.WwiseProjectFound = true; } AkWwiseProjectInfo.GetData().EventWwu.Clear(); AkWwiseProjectInfo.GetData().AuxBusWwu.Clear(); AkWwiseProjectInfo.GetData().StateWwu.Clear(); AkWwiseProjectInfo.GetData().SwitchWwu.Clear(); AkWwiseProjectInfo.GetData().BankWwu.Clear(); s_currentWwuCnt = 0; List <AssetType> AssetsToParse = new List <AssetType>(); AssetsToParse.Add(new AssetType("Events", "Event", "")); AssetsToParse.Add(new AssetType("States", "StateGroup", "State")); AssetsToParse.Add(new AssetType("Switches", "SwitchGroup", "Switch")); AssetsToParse.Add(new AssetType("Master-Mixer Hierarchy", "AuxBus", "")); AssetsToParse.Add(new AssetType("SoundBanks", "SoundBank", "")); s_totWwuCnt = GetNumOfWwus(AssetsToParse); foreach (AssetType asset in AssetsToParse) { bool bSuccess = PopulateListOfType(asset); if (!bSuccess) { Debug.LogError("Error when parsing the work units for " + asset.XmlElementName + " ."); } else { AkWwiseProjectInfo.GetData().GetWwuListByString(asset.RootDirectoryName).Sort(AkWwiseProjectData.s_compareByPhysicalPath); } } EditorUtility.ClearProgressBar(); AkWwiseProjectInfo.GetData().SetLastPopulateTime(DateTime.Now); } catch (Exception e) { Debug.LogError(e.ToString()); EditorUtility.ClearProgressBar(); } }
public static void SetupSoundbankSetting() { var WprojPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, WwiseSettings.LoadSettings().WwiseProjectPath); AkUtilities.EnableBoolSoundbankSettingInWproj("SoundBankGenerateEstimatedDuration", WprojPath); UnityEditor.EditorApplication.update += RunOnce; AkWwiseXMLWatcher.Instance.XMLUpdated += UpdateAllClips; }
void OnGUI() { // Make sure everything is initialized // Use soundbank path, because Wwise project path can be empty. if (String.IsNullOrEmpty(WwiseSetupWizard.Settings.SoundbankPath) && WwiseSetupWizard.Settings.WwiseProjectPath == null) { WwiseSetupWizard.Settings = WwiseSettings.LoadSettings(); } string initialProject = WwiseSetupWizard.Settings.WwiseProjectPath; if (VersionStyle == null) { InitGuiStyles(); } GUILayout.Label(m_WwiseVersionString, VersionStyle); DrawSettingsPart(); string newProject = WwiseSetupWizard.Settings.WwiseProjectPath; // DrawSettingsPart modifies WwiseSetupWizard.Settings.WwiseProjectPath directly. if (initialProject != newProject) { ApplyNewProject = true; } GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("OK", GUILayout.Width(60))) { if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.SoundbankPath)) { EditorUtility.DisplayDialog("Error", "Please fill in the required settings", "Ok"); } if (AkWwiseSettingsWindow.m_oldCreateWwiseGlobal != WwiseSetupWizard.Settings.CreateWwiseGlobal) { AkInitializer[] AkInitializers = UnityEngine.Object.FindObjectsOfType(typeof(AkInitializer)) as AkInitializer[]; if (WwiseSetupWizard.Settings.CreateWwiseGlobal == true) { if (AkInitializers.Length == 0) { //No Wwise object in this scene, create one so that the sound engine is initialized and terminated properly even if the scenes are loaded //in the wrong order. GameObject objWwise = new GameObject("WwiseGlobal"); //Attach initializer and terminator components AkInitializer init = objWwise.AddComponent <AkInitializer>(); AkWwiseProjectInfo.GetData().CopyInitSettings(init); } } else { if (AkInitializers.Length != 0 && AkInitializers[0].gameObject.name == "WwiseGlobal") { GameObject.DestroyImmediate(AkInitializers[0].gameObject); } } } if (AkWwiseSettingsWindow.m_oldCreateWwiseListener != WwiseSetupWizard.Settings.CreateWwiseListener) { if (Camera.main != null) { AkAudioListener akListener = Camera.main.GetComponentInChildren <AkAudioListener>(); if (WwiseSetupWizard.Settings.CreateWwiseListener) { if (akListener == null) { akListener = Undo.AddComponent <AkAudioListener>(Camera.main.gameObject); AkGameObj akGameObj = akListener.GetComponentInChildren <AkGameObj>(); akGameObj.isEnvironmentAware = false; } // If Unity had already an audio listener, we want to remove it when adding our own. AudioListener unityListener = Camera.main.GetComponentInChildren <AudioListener>(); if (unityListener != null) { Component.DestroyImmediate(unityListener); } } } } if (m_oldShowMissingRigidBodyWarning != WwiseSetupWizard.Settings.ShowMissingRigidBodyWarning) { InternalEditorUtility.RepaintAllViews(); } WwiseSettings.SaveSettings(WwiseSetupWizard.Settings); CloseWindow(); // Pop the Picker window so the user can start working right away AkWwiseProjectInfo.GetData(); // Load data if (ApplyNewProject) { //Clear the data, the project path changed. AkWwiseProjectInfo.GetData().Reset(); ApplyNewProject = false; AkWwisePicker.WwiseProjectFound = true; } AkWwiseProjectInfo.Populate(); AkWwisePicker.PopulateTreeview(); AkWwisePicker.init(); } if (GUILayout.Button("Cancel", GUILayout.Width(60))) { WwiseSetupWizard.Settings = WwiseSettings.LoadSettings(true); CloseWindow(); } GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); GUILayout.EndHorizontal(); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); GUILayout.EndVertical(); }
// Generate all the SoundBanks for all the supported platforms in the Wwise project. This effectively calls Wwise for the project // that is configured in the UnityWwise integration. public static void GenerateSoundbanks(System.Collections.Generic.List <string> platforms = null) { var Settings = WwiseSettings.LoadSettings(); var wwiseProjectFullPath = GetFullPath(UnityEngine.Application.dataPath, Settings.WwiseProjectPath); if (IsSoundbankOverrideEnabled(wwiseProjectFullPath)) { UnityEngine.Debug.LogWarning( "The SoundBank generation process ignores the SoundBank Settings' Overrides currently enabled in the User settings. The project's SoundBank settings will be used."); } var wwiseCli = GetWwiseCLI(); if (wwiseCli == null) { UnityEngine.Debug.LogError("Couldn't locate WwiseCLI, unable to generate SoundBanks."); return; } #if UNITY_EDITOR_WIN var command = wwiseCli; var arguments = ""; #elif UNITY_EDITOR_OSX var command = "/bin/sh"; var arguments = "\"" + wwiseCli + "\""; #else var command = ""; var arguments = ""; #endif arguments += " \"" + wwiseProjectFullPath + "\""; if (platforms != null) { foreach (var platform in platforms) { if (!string.IsNullOrEmpty(platform)) { arguments += " -Platform " + platform; } } } arguments += " -GenerateSoundBanks"; var output = ExecuteCommandLine(command, arguments); var success = output.Contains("Process completed successfully."); var warning = output.Contains("Process completed with warning"); var message = "WwiseUnity: SoundBanks generation " + (success ? "successful" : (warning ? "has warning(s)" : "error")) + ":\n" + output; if (success) { UnityEngine.Debug.Log(message); } else if (warning) { UnityEngine.Debug.LogWarning(message); } else { UnityEngine.Debug.LogError(message); } UnityEditor.AssetDatabase.Refresh(); }
private void OnGUI() { // Make sure everything is initialized // Use soundbank path, because Wwise project path can be empty. if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.SoundbankPath) && WwiseSetupWizard.Settings.WwiseProjectPath == null) { WwiseSetupWizard.Settings = WwiseSettings.LoadSettings(); } var initialProject = WwiseSetupWizard.Settings.WwiseProjectPath; if (VersionStyle == null) { InitGuiStyles(); } UnityEngine.GUILayout.Label(m_WwiseVersionString, VersionStyle); DrawSettingsPart(); // DrawSettingsPart modifies WwiseSetupWizard.Settings.WwiseProjectPath directly. var newProject = WwiseSetupWizard.Settings.WwiseProjectPath; if (initialProject != newProject) { ApplyNewProject = true; } using (new UnityEngine.GUILayout.VerticalScope()) { UnityEngine.GUILayout.FlexibleSpace(); using (new UnityEngine.GUILayout.HorizontalScope()) { UnityEngine.GUILayout.FlexibleSpace(); if (UnityEngine.GUILayout.Button("OK", UnityEngine.GUILayout.Width(60))) { if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.SoundbankPath)) { UnityEditor.EditorUtility.DisplayDialog("Error", "Please fill in the required settings", "Ok"); } if (m_oldCreateWwiseGlobal != WwiseSetupWizard.Settings.CreateWwiseGlobal) { // var AkInitializers = FindObjectsOfType<AkInitializer>(); // if (WwiseSetupWizard.Settings.CreateWwiseGlobal) // { // if (AkInitializers.Length == 0) // { // //No Wwise object in this scene, create one so that the sound engine is initialized and terminated properly even if the scenes are loaded // //in the wrong order. // //var objWwise = new UnityEngine.GameObject("WwiseGlobal"); // // //UnityEditor.Undo.AddComponent<AkInitializer>(objWwise); // } // } // else if (AkInitializers.Length != 0 && AkInitializers[0].gameObject.name == "WwiseGlobal") // UnityEditor.Undo.DestroyObjectImmediate(AkInitializers[0].gameObject); } if (m_oldCreateWwiseListener != WwiseSetupWizard.Settings.CreateWwiseListener) { if (WwiseSetupWizard.Settings.CreateWwiseListener) { AkUtilities.RemoveUnityAudioListenerFromMainCamera(); AkUtilities.AddAkAudioListenerToMainCamera(); } } if (m_oldShowMissingRigidBodyWarning != WwiseSetupWizard.Settings.ShowMissingRigidBodyWarning) { UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); } WwiseSettings.SaveSettings(WwiseSetupWizard.Settings); CloseWindow(); // Pop the Picker window so the user can start working right away AkWwiseProjectInfo.GetData(); // Load data if (ApplyNewProject) { //Clear the data, the project path changed. AkWwiseProjectInfo.GetData().Reset(); ApplyNewProject = false; AkUtilities.IsWwiseProjectAvailable = true; } AkWwiseProjectInfo.Populate(); AkWwisePicker.PopulateTreeview(); AkWwisePicker.init(); } if (UnityEngine.GUILayout.Button("Cancel", UnityEngine.GUILayout.Width(60))) { WwiseSetupWizard.Settings = WwiseSettings.LoadSettings(true); CloseWindow(); } UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing); } UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing); } }
// Called when changes are made to the scene and when a new scene is created. public static void CheckWwiseGlobalExistance() { var settings = WwiseSettings.LoadSettings(); var activeSceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; if (string.IsNullOrEmpty(s_CurrentScene) || !s_CurrentScene.Equals(activeSceneName)) { // Look for a game object which has the initializer component var AkInitializers = UnityEngine.Object.FindObjectsOfType <AkInitializer>(); if (AkInitializers.Length == 0) { if (settings.CreateWwiseGlobal) { //No Wwise object in this scene, create one so that the sound engine is initialized and terminated properly even if the scenes are loaded //in the wrong order. var objWwise = new UnityEngine.GameObject("WwiseGlobal"); //Attach initializer and terminator components var init = objWwise.AddComponent <AkInitializer>(); AkWwiseProjectInfo.GetData().CopyInitSettings(init); } } else { if (settings.CreateWwiseGlobal == false && AkInitializers[0].gameObject.name == "WwiseGlobal") { UnityEngine.Object.DestroyImmediate(AkInitializers[0].gameObject); } //All scenes will share the same initializer. So expose the init settings consistently across scenes. AkWwiseProjectInfo.GetData().CopyInitSettings(AkInitializers[0]); } if (UnityEngine.Camera.main != null) { var mainCameraGameObject = UnityEngine.Camera.main.gameObject; var akListener = mainCameraGameObject.GetComponent <AkAudioListener>(); if (settings.CreateWwiseListener) { var listener = mainCameraGameObject.GetComponent <UnityEngine.AudioListener>(); if (listener != null) { UnityEngine.Object.DestroyImmediate(listener); } // Add the AkAudioListener script if (akListener == null) { akListener = mainCameraGameObject.AddComponent <AkAudioListener>(); var akGameObj = akListener.GetComponent <AkGameObj>(); akGameObj.isEnvironmentAware = false; UnityEngine.Debug.LogWarning( "Automatically added AkAudioListener to Main Camera. Go to \"Edit > Wwise Settings...\" to disable this functionality."); } } } s_CurrentScene = activeSceneName; } }
// Called when changes are made to the scene and when a new scene is created. public static void CheckWwiseGlobalExistance() { var settings = WwiseSettings.LoadSettings(); var activeSceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; if (string.IsNullOrEmpty(s_CurrentScene) || !s_CurrentScene.Equals(activeSceneName)) { //{ // // Look for a game object which has the initializer component // var akRoutes = UnityEngine.Object.FindObjectsOfType<WisePluginNotificationRoute>(); // if (akRoutes.Length == 0) // { // while (true) // { // var oldObj = UnityEngine.GameObject.Find("WwiseGlobal"); // if(oldObj == null) // break; // UnityEditor.Undo.DestroyObjectImmediate(oldObj); // } // var objWwise = new UnityEngine.GameObject("WwiseGlobal"); // var init = UnityEditor.Undo.AddComponent<AkInitializer>(objWwise); // //Attach initializer and terminator components // UnityEditor.Undo.AddComponent<WisePluginNotificationRoute>(objWwise); // AkWwiseProjectInfo.GetData().CopyInitSettings(init); // //if (false) // //{ // // //No Wwise object in this scene, create one so that the sound engine is initialized and terminated properly even if the scenes are loaded // // //in the wrong order. // // //var oldObj = UnityEngine.GameObject.Find("WwiseGlobal"); // // //while (true) // // //{ // // //} // // //if (oldObj) // // //{ // // // if (!oldObj.GetComponent<WisePluginNotificationRoute>() || !oldObj.GetComponent<AkInitializer>()) // // // { // // // UnityEngine.Object.Destroy(oldObj); // // // var objWwise = new UnityEngine.GameObject("WwiseGlobal"); // // // var init = UnityEditor.Undo.AddComponent<AkInitializer>(objWwise); // // // //Attach initializer and terminator components // // // UnityEditor.Undo.AddComponent<WisePluginNotificationRoute>(objWwise); // // // AkWwiseProjectInfo.GetData().CopyInitSettings(init); // // // } // // //} // //} // } // else // { // for(int i=1;i< akRoutes.Length;i++) // { // UnityEditor.Undo.DestroyObjectImmediate(akRoutes[i].gameObject); // } // //if (settings.CreateWwiseGlobal == false && AkInitializers[0].gameObject.name == "WwiseGlobal") // // UnityEditor.Undo.DestroyObjectImmediate(AkInitializers[0].gameObject); // //All scenes will share the same initializer. So expose the init settings consistently across scenes. // AkWwiseProjectInfo.GetData().CopyInitSettings(akRoutes[0].GetComponent<AkInitializer>()); // } if (settings.CreateWwiseListener) { AkUtilities.RemoveUnityAudioListenerFromMainCamera(); AkUtilities.AddAkAudioListenerToMainCamera(true); } s_CurrentScene = activeSceneName; } }
void OnGUI() { // Make sure everything is initialized if (m_Logo == null) { FetchWwiseLogo(); } if (WelcomeStyle == null) { InitGuiStyles(); } // Use soundbank path, because Wwise project path can be empty. if (String.IsNullOrEmpty(Settings.SoundbankPath) && Settings.WwiseProjectPath == null) { Settings = WwiseSettings.LoadSettings(); } GUILayout.BeginHorizontal("box"); GUILayout.Label(m_Logo, GUILayout.Width(m_Logo.width)); GUILayout.Label("Welcome to the Wwise Unity Integration " + m_newIntegrationVersion + "!", WelcomeStyle, GUILayout.Height(m_Logo.height)); GUILayout.EndHorizontal(); // Make the HelpBox font size a little bigger GUILayout.Label( @"This setup wizard will perform the first-time setup of the Wwise Unity integration. If this is the first time the Wwise Unity integration is installed for this game project, simply fill in the required fields, and click ""Start Installation"". If a previous version of the integration has already been installed on this game project, it is still recommended to fill out the required settings below and completing the installation. The game project will be updated to match the new version of the Wwise Unity integration. To get more information on the installation process, please refer to the ""Install the integration in a Unity project"" section of the integration documentation, found under the menu Help -> Wwise Help. This integration relies on data from a " + m_newIntegrationVersion + @" Wwise project. Note that it is recommended for the Wwise project to reside in the game project's root folder. For more information on a particular setting, hover your mouse over it.", HelpStyle); DrawSettingsPart(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Start Installation", GUILayout.Width(200))) { if (string.IsNullOrEmpty(Settings.WwiseProjectPath) || string.IsNullOrEmpty(Settings.SoundbankPath)) { EditorUtility.DisplayDialog("Error", "Please fill all mandatory settings", "Ok"); } else { WwiseSettings.SaveSettings(Settings); if (Setup()) { Debug.Log("WwiseUnity integration installation completed successfully"); } else { Debug.LogError("Could not complete Wwise Unity integration installation"); } // Setup done; close the window WwiseSetupWizard.CloseWindow(); if (!string.IsNullOrEmpty(Settings.WwiseProjectPath)) { // Pop the Picker window so the user can start working right away AkWwisePicker.init(); } ShowHelp(); } } if (GUILayout.Button("Cancel Installation", GUILayout.Width(200))) { // Ask "Are you sure?" if (EditorUtility.DisplayDialog("Warning", "This will completely remove the Wwise Unity Integration. Are you sure?", "Yes", "No")) { UninstallIntegration(); WwiseSetupWizard.CloseWindow(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.EndVertical(); }
// 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); }
void OnGUI() { // Make sure everything is initialized // Use soundbank path, because Wwise project path can be empty. if (String.IsNullOrEmpty(WwiseSetupWizard.Settings.SoundbankPath) && WwiseSetupWizard.Settings.WwiseProjectPath == null) { WwiseSetupWizard.Settings = WwiseSettings.LoadSettings(); } if (VersionStyle == null) { InitGuiStyles(); } GUILayout.Label(m_WwiseVersionString, VersionStyle); DrawSettingsPart(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("OK", GUILayout.Width(60))) { if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.SoundbankPath)) { EditorUtility.DisplayDialog("Error", "Please fill in the required settings", "Ok"); } if (WwiseUpdateSettings.m_oldCreateWwiseGlobal != WwiseSetupWizard.Settings.CreateWwiseGlobal) { AkInitializer[] AkInitializers = UnityEngine.Object.FindObjectsOfType(typeof(AkInitializer)) as AkInitializer[]; if (WwiseSetupWizard.Settings.CreateWwiseGlobal == true) { if (AkInitializers.Length == 0) { //No Wwise object in this scene, create one so that the sound engine is initialized and terminated properly even if the scenes are loaded //in the wrong order. GameObject objWwise = new GameObject("WwiseGlobal"); //Attach initializer and terminator components AkInitializer init = objWwise.AddComponent <AkInitializer>(); AkWwiseProjectInfo.GetData().CopyInitSettings(init); } } else { if (AkInitializers.Length != 0 && AkInitializers[0].gameObject.name == "WwiseGlobal") { GameObject.DestroyImmediate(AkInitializers[0].gameObject); } } } if (WwiseUpdateSettings.m_oldCreateWwiseListener != WwiseSetupWizard.Settings.CreateWwiseListener) { if (Camera.main != null) { AkAudioListener akListener = Camera.main.GetComponentInChildren <AkAudioListener>(); if (akListener != null && WwiseSetupWizard.Settings.CreateWwiseListener == false) { Component.DestroyImmediate(akListener); } if (WwiseSetupWizard.Settings.CreateWwiseListener == true) { Camera.main.gameObject.AddComponent <AkAudioListener>(); } } } WwiseSettings.SaveSettings(WwiseSetupWizard.Settings); CloseWindow(); // Pop the Picker window so the user can start working right away AkWwiseProjectInfo.GetData(); // Load data AkWwiseProjectInfo.Populate(); AkWwisePicker.PopulateTreeview(); AkWwisePicker.init(); } if (GUILayout.Button("Cancel", GUILayout.Width(60))) { WwiseSetupWizard.Settings = WwiseSettings.LoadSettings(true); CloseWindow(); } GUILayout.Space(5); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.EndVertical(); }
public static void Update(bool forceUpdate = false) { //Gather all GeneratedSoundBanks folder from the project var allPaths = AkUtilities.GetAllBankPaths(); var bNeedRefresh = false; var projectPath = System.IO.Path.GetDirectoryName(AkUtilities.GetFullPath(UnityEngine.Application.dataPath, WwiseSettings.LoadSettings().WwiseProjectPath)); var pfMap = AkUtilities.GetPlatformMapping(); //Go through all BasePlatforms foreach (var pairPF in pfMap) { //Go through all custom platforms related to that base platform and check if any of the bank files were updated. var bParse = forceUpdate; var fullPaths = new System.Collections.Generic.List <string>(); foreach (var customPF in pairPF.Value) { string bankPath; if (!allPaths.TryGetValue(customPF, out bankPath)) { continue; } var pluginFile = ""; try { pluginFile = System.IO.Path.Combine(projectPath, System.IO.Path.Combine(bankPath, "PluginInfo.xml")); pluginFile = pluginFile.Replace('/', System.IO.Path.DirectorySeparatorChar); if (!System.IO.File.Exists(pluginFile)) { //Try in StreamingAssets too. pluginFile = System.IO.Path.Combine(System.IO.Path.Combine(AkBasePathGetter.GetFullSoundBankPath(), customPF), "PluginInfo.xml"); if (!System.IO.File.Exists(pluginFile)) { continue; } } fullPaths.Add(pluginFile); var t = System.IO.File.GetLastWriteTime(pluginFile); var lastTime = System.DateTime.MinValue; s_LastParsed.TryGetValue(customPF, out lastTime); if (lastTime < t) { bParse = true; s_LastParsed[customPF] = t; } } catch (System.Exception ex) { UnityEngine.Debug.LogError("WwiseUnity: " + pluginFile + " could not be parsed. " + ex.Message); } } if (bParse) { var platform = pairPF.Key; var newDlls = ParsePluginsXML(platform, fullPaths); System.Collections.Generic.HashSet <string> oldDlls = null; //Remap base Wwise platforms to Unity platform folders names if (platform.Contains("Vita")) { platform = "Vita"; } //else other platforms already have the right name s_PerPlatformPlugins.TryGetValue(platform, out oldDlls); s_PerPlatformPlugins[platform] = newDlls; //Check if there was any change. if (!bNeedRefresh && oldDlls != null) { if (oldDlls.Count == newDlls.Count) { oldDlls.IntersectWith(newDlls); } bNeedRefresh |= oldDlls.Count != newDlls.Count; } else { bNeedRefresh |= newDlls.Count > 0; } } } if (bNeedRefresh) { ActivatePluginsForEditor(); } var currentConfig = GetCurrentConfig(); CheckMenuItems(currentConfig); }
public static void Update() { //Gather all GeneratedSoundBanks folder from the project IDictionary <string, string> allPaths = AkUtilities.GetAllBankPaths(); bool bNeedRefresh = false; string projectPath = Path.GetDirectoryName(AkUtilities.GetFullPath(Application.dataPath, WwiseSettings.LoadSettings().WwiseProjectPath)); IDictionary <string, HashSet <string> > pfMap = AkUtilities.GetPlatformMapping(); //Go through all BasePlatforms foreach (KeyValuePair <string, HashSet <string> > pairPF in pfMap) { //Go through all custom platforms related to that base platform and check if any of the bank files were updated. bool bParse = false; List <string> fullPaths = new List <string>(); foreach (string customPF in pairPF.Value) { string bankPath; if (!allPaths.TryGetValue(customPF, out bankPath)) { continue; } string pluginFile = ""; try { pluginFile = Path.Combine(projectPath, Path.Combine(bankPath, "PluginInfo.xml")); pluginFile = pluginFile.Replace('/', Path.DirectorySeparatorChar); if (!File.Exists(pluginFile)) { //Try in StreamingAssets too. pluginFile = Path.Combine(Path.Combine(AkBasePathGetter.GetFullSoundBankPath(), customPF), "PluginInfo.xml"); if (!File.Exists(pluginFile)) { continue; } } fullPaths.Add(pluginFile); DateTime t = File.GetLastWriteTime(pluginFile); DateTime lastTime = DateTime.MinValue; s_LastParsed.TryGetValue(customPF, out lastTime); if (lastTime < t) { bParse = true; s_LastParsed[customPF] = t; } } catch (System.Exception ex) { Debug.LogError("Wwise: " + pluginFile + " could not be parsed. " + ex.Message); } } if (bParse) { HashSet <string> newDlls = ParsePluginsXML(fullPaths); HashSet <string> oldDlls = null; string platform = pairPF.Key; //Remap base Wwise platforms to Unity platform folders names if (platform == "WiiUSW") { platform = "WiiU"; } else if (platform.Contains("Vita")) { platform = "Vita"; } //else other platform already have the right name s_PerPlatformPlugins.TryGetValue(platform, out oldDlls); s_PerPlatformPlugins[platform] = newDlls; //Check if there was any change. if (!bNeedRefresh && oldDlls != null) { if (oldDlls.Count == newDlls.Count) { oldDlls.IntersectWith((IEnumerable <string>)newDlls); } bNeedRefresh |= oldDlls.Count != newDlls.Count; } else { bNeedRefresh |= newDlls.Count > 0; } } } if (bNeedRefresh) { RefreshPlugins(); } }
static public void CheckWwiseGlobalExistance() { WwiseSettings settings = WwiseSettings.LoadSettings(); #if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 if (!settings.OldProject && (String.IsNullOrEmpty(EditorApplication.currentScene) || s_CurrentScene != EditorApplication.currentScene)) #else string activeSceneName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name; if (!settings.OldProject && s_CurrentScene != activeSceneName) #endif { // Look for a game object which has the initializer component AkInitializer[] AkInitializers = UnityEngine.Object.FindObjectsOfType(typeof(AkInitializer)) as AkInitializer[]; if (AkInitializers.Length == 0) { if (settings.CreateWwiseGlobal == true) { //No Wwise object in this scene, create one so that the sound engine is initialized and terminated properly even if the scenes are loaded //in the wrong order. GameObject objWwise = new GameObject("WwiseGlobal"); //Attach initializer and terminator components AkInitializer init = objWwise.AddComponent <AkInitializer>(); AkWwiseProjectInfo.GetData().CopyInitSettings(init); } } else { if (settings.CreateWwiseGlobal == false && AkInitializers[0].gameObject.name == "WwiseGlobal") { GameObject.DestroyImmediate(AkInitializers[0].gameObject); } //All scenes will share the same initializer. So expose the init settings consistently across scenes. AkWwiseProjectInfo.GetData().CopyInitSettings(AkInitializers[0]); } AkAudioListener[] akAudioListeners = UnityEngine.Object.FindObjectsOfType(typeof(AkAudioListener)) as AkAudioListener[]; if (akAudioListeners.Length == 0) { // Remove the audio listener script if (Camera.main != null && settings.CreateWwiseListener == true) { AudioListener listener = Camera.main.gameObject.GetComponent <AudioListener>(); if (listener != null) { Component.DestroyImmediate(listener); } // Add the AkAudioListener script if (Camera.main.gameObject.GetComponent <AkAudioListener>() == null) { Camera.main.gameObject.AddComponent <AkAudioListener>(); } } } else { foreach (AkAudioListener akListener in akAudioListeners) { if (settings.CreateWwiseListener == false && akListener.gameObject == Camera.main.gameObject) { Component.DestroyImmediate(akListener); } } } #if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 s_CurrentScene = EditorApplication.currentScene; #else s_CurrentScene = activeSceneName; #endif } }
void OnEnable() { if (string.IsNullOrEmpty(WwiseSettings.LoadSettings().WwiseProjectPath)) { return; } string[] dir = { "Events", "States", "Switches", "Master-Mixer Hierarchy", "SoundBanks" }; string wwiseProjectPath = Path.GetDirectoryName(AkUtilities.GetFullPath(Application.dataPath, WwiseSettings.LoadSettings().WwiseProjectPath)); try { for (int i = 0; i < dir.Length; i++) { DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(wwiseProjectPath, dir[i])); FileInfo[] files = dirInfo.GetFiles("*.wwu", SearchOption.AllDirectories); ArrayList list = AkWwiseProjectInfo.GetData().GetWwuListByString(dir[i]); List <string> pathList = new List <string>(list.Count); for (int j = 0; j < list.Count; j++) { pathList.Add(Path.Combine(wwiseProjectPath, (list[j] as AkWwiseProjectData.WorkUnit).PhysicalPath)); } foreach (FileInfo file in files) { if (file.LastWriteTime.CompareTo(AkWwiseProjectInfo.GetData().GetLastPopulateTime()) > 0) { AkWwiseWWUBuilder.s_createdWwu.Add(file.FullName); } pathList.Remove(file.FullName); } AkWwiseWWUBuilder.s_deletedWwu.AddRange(pathList); } if (AkWwiseWWUBuilder.s_createdWwu.Count != 0 || AkWwiseWWUBuilder.s_deletedWwu.Count != 0) { treeView.SaveExpansionStatus(); AkWwiseWWUBuilder.AutoPopulate(); PopulateTreeview(); } } catch (Exception) { WwiseProjectFound = false; } }