Inheritance: EditorWindow
Example #1
0
    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();
    }
    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());
                }
            }
        }
    }
Example #3
0
    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());
            }
        }
    }
Example #4
0
    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();
    }
Example #5
0
    public static void CheckPicker()
    {
        if (EditorApplication.isPlayingOrWillChangePlaymode || EditorApplication.isCompiling)
        {
            // Skip if not in the right mode, wait for the next callback to see if we can proceed then.
            EditorApplication.delayCall += CheckPicker;
            return;
        }

        WwiseSettings settings = WwiseSettings.LoadSettings();

        if (!settings.CreatedPicker)
        {
            // Delete all the ghost tabs (Failed to load).
            EditorWindow[] windows = Resources.FindObjectsOfTypeAll <EditorWindow>();
            if (windows != null && windows.Length > 0)
            {
                foreach (EditorWindow window in windows)
                {
                    string windowTitle = window.titleContent.text;

                    if (windowTitle.Equals("Failed to load") || windowTitle.Equals("AkWwisePicker"))
                    {
                        try
                        {
                            window.Close();
                        }
                        catch (Exception)
                        {
                            // Do nothing here, this shoudn't cause any problem, however there has been
                            // occurences of Unity crashing on a null reference inside that method.
                        }
                    }
                }
            }

            ClearConsole();

            // TODO: If no scene is loaded and we are using the demo scene, automatically load it to display it.

            // Populate the picker
            AkWwiseProjectInfo.GetData();             // Load data
            if (!String.IsNullOrEmpty(settings.WwiseProjectPath))
            {
                AkWwiseProjectInfo.Populate();
                AkWwisePicker.init();

                if (AkWwiseProjectInfo.GetData().autoPopulateEnabled)
                {
                    AkWwiseWWUBuilder.StartWWUWatcher();
                }

                settings.CreatedPicker = true;
                WwiseSettings.SaveSettings(settings);
            }
        }

        EditorApplication.delayCall += CheckPendingExecuteMethod;
    }
    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();
        }
    }
Example #9
0
    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;
        }
    }
Example #10
0
    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();
    }
Example #12
0
    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);
        }
    }
    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();
    }
    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);
    }
Example #16
0
    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();
    }