public void SaveExpansionStatus() { if (AkUtilities.IsWwiseProjectAvailable) { if (RootItem.Header == "Root item") { // We were unpopulated, no need to save. But we still need to display the correct data, though. AkWwisePicker.PopulateTreeview(); return; } if (AkWwiseProjectInfo.GetData() != null) { var PreviousExpandedItems = AkWwiseProjectInfo.GetData().ExpandedItems; AkWwiseProjectInfo.GetData().ExpandedItems.Clear(); var path = string.Empty; if (RootItem.HasChildItems() && RootItem.IsExpanded) { SaveExpansionStatus(RootItem, path); } AkWwiseProjectInfo.GetData().ExpandedItems.Sort(); if (System.Linq.Enumerable.Count(System.Linq.Enumerable.Except(AkWwiseProjectInfo.GetData().ExpandedItems, PreviousExpandedItems)) > 0) { UnityEditor.EditorUtility.SetDirty(AkWwiseProjectInfo.GetData()); } } } }
private static void PostImportFunction() { EditorApplication.hierarchyWindowChanged += CheckWwiseGlobalExistance; EditorApplication.delayCall += CheckPicker; if (EditorApplication.isPlayingOrWillChangePlaymode || EditorApplication.isCompiling) { return; } try { if (File.Exists(Application.dataPath + 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 (Exception e) { Debug.Log(e.ToString()); } //Check if a WwiseGlobal object exists in the current scene CheckWwiseGlobalExistance(); }
private static void PostImportFunction() { #if UNITY_2018_1_OR_NEWER UnityEditor.EditorApplication.hierarchyChanged += CheckWwiseGlobalExistance; #else UnityEditor.EditorApplication.hierarchyWindowChanged += CheckWwiseGlobalExistance; #endif UnityEditor.EditorApplication.delayCall += CheckPicker; if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || UnityEditor.EditorApplication.isCompiling) { return; } try { if (!string.IsNullOrEmpty(AkWwiseEditorSettings.Instance.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 void SaveExpansionStatus() { if (AkWwisePicker.WwiseProjectFound == true) { if (RootItem.Header == "Root item") { // We were unpopulated, no need to save. But we still need to display the correct data, though. AkWwisePicker.PopulateTreeview(); return; } if (AkWwiseProjectInfo.GetData() != null) { AkWwiseProjectInfo.GetData().ExpandedItems.Clear(); string path = string.Empty; if (RootItem.HasChildItems() && RootItem.IsExpanded) { SaveExpansionStatus(RootItem, path); } AkWwiseProjectInfo.GetData().ExpandedItems.Sort(); EditorUtility.SetDirty(AkWwiseProjectInfo.GetData()); } } }
static void PostImportFunction() { // Do nothing in batch mode string[] arguments = Environment.GetCommandLineArgs(); if (Array.IndexOf(arguments, "-nographics") != -1) { return; } EditorApplication.hierarchyWindowChanged += CheckWwiseGlobalExistance; try { if (!File.Exists(Application.dataPath + Path.DirectorySeparatorChar + WwiseSettings.WwiseSettingsFilename)) { WwiseSetupWizard.Init(); return; } else { WwiseSetupWizard.Settings = WwiseSettings.LoadSettings(); AkWwiseProjectInfo.GetData(); #if !UNITY_5 // Check if there are some new platforms to install. InstallNewPlatforms(); #else if (string.IsNullOrEmpty(AkWwiseProjectInfo.GetData().CurrentPluginConfig)) { AkWwiseProjectInfo.GetData().CurrentPluginConfig = AkPluginActivator.CONFIG_PROFILE; } AkPluginActivator.RefreshPlugins(); #endif } if (!string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath)) { AkWwisePicker.PopulateTreeview(); if (AkWwiseProjectInfo.GetData().autoPopulateEnabled) { AkWwiseWWUWatcher.GetInstance().StartWWUWatcher(); } } } catch (Exception e) { Debug.Log(e.ToString()); } //Check if a WwiseGlobal object exists in the current scene CheckWwiseGlobalExistance(); // If demo scene, remove file that should only be there on import string filename = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Application.dataPath, "Wwise"), "Editor"), "WwiseSetupWizard"), "AkWwisePopPicker.cs"); if (File.Exists(filename)) { EditorApplication.delayCall += DeletePopPicker; } }
static void PostImportFunction() { EditorApplication.hierarchyWindowChanged += CheckWwiseGlobalExistance; if (EditorApplication.isPlayingOrWillChangePlaymode || EditorApplication.isCompiling) { return; } // Do nothing in batch mode string[] arguments = Environment.GetCommandLineArgs(); if (Array.IndexOf(arguments, "-nographics") != -1) { return; } try { if (!File.Exists(Application.dataPath + Path.DirectorySeparatorChar + WwiseSettings.WwiseSettingsFilename)) { WwiseSetupWizard.Init(); return; } else { WwiseSetupWizard.Settings = WwiseSettings.LoadSettings(); AkWwiseProjectInfo.GetData(); } if (!string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath)) { AkWwiseProjectInfo.Populate(); AkWwisePicker.PopulateTreeview(); if (AkWwiseProjectInfo.GetData().autoPopulateEnabled) { AkWwiseWWUBuilder.StartWWUWatcher(); } } } catch (Exception e) { Debug.Log(e.ToString()); } //Check if a WwiseGlobal object exists in the current scene CheckWwiseGlobalExistance(); // If demo scene, remove file that should only be there on import string filename = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Application.dataPath, "Wwise"), "Editor"), "WwiseSetupWizard"), "AkWwisePopPicker.cs"); if (File.Exists(filename)) { EditorApplication.delayCall += DeletePopPicker; } }
public static void Tick() { if (s_populateNow) { AkWwisePicker.treeView.SaveExpansionStatus(); AutoPopulate(); AkWwisePicker.PopulateTreeview(); s_populateNow = false; //Make sure that the Wwise picker and the inspector are updated AkUtilities.RepaintInspector(); } }
public static void Tick() { if (AkWwiseProjectInfo.GetData().autoPopulateEnabled&& DateTime.Now.Subtract(s_lastFileCheck).Seconds > s_SecondsBetweenChecks && !EditorApplication.isCompiling && !EditorApplication.isPlayingOrWillChangePlaymode) { AkWwisePicker.treeView.SaveExpansionStatus(); if (AutoPopulate()) { AkWwisePicker.PopulateTreeview(); //Make sure that the Wwise picker and the inspector are updated AkUtilities.RepaintInspector(); } s_lastFileCheck = DateTime.Now; } }
private static void Tick() { isTicking = true; if (AkWwiseProjectInfo.GetData() != null) { if (System.DateTime.Now.Subtract(s_lastFileCheck).Seconds > s_SecondsBetweenChecks && !UnityEditor.EditorApplication.isCompiling && !UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode && AkWwiseProjectInfo.GetData().autoPopulateEnabled) { AkWwisePicker.treeView.SaveExpansionStatus(); if (Populate()) { AkWwiseXMLBuilder.Populate(); AkWwisePicker.PopulateTreeview(); //Make sure that the Wwise picker and the inspector are updated AkUtilities.RepaintInspector(); } s_lastFileCheck = System.DateTime.Now; } } }
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(); }
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); } }
// 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(); }