Populate() public static method

public static Populate ( ) : bool
return bool
Esempio n. 1
0
    public void OnGUI()
    {
        GUILayout.BeginHorizontal("Box");

        AkWwiseProjectInfo.GetData().autoPopulateEnabled = GUILayout.Toggle(AkWwiseProjectInfo.GetData().autoPopulateEnabled, "Auto populate");

        if (AkWwiseProjectInfo.GetData().autoPopulateEnabled&& WwiseProjectFound)
        {
            AkWwiseWWUWatcher.GetInstance().StartWWUWatcher();
        }
        else
        {
            AkWwiseWWUWatcher.GetInstance().StopWWUWatcher();
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Refresh Project", GUILayout.Width(200)))
        {
            treeView.SaveExpansionStatus();
            AkWwiseProjectInfo.Populate();
            PopulateTreeview();
        }

        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        treeView.DisplayTreeView(TreeViewControl.DisplayTypes.USE_SCROLL_VIEW);

        if (GUI.changed && WwiseProjectFound)
        {
            EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        }
        // TODO: RTP Parameters List
    }
Esempio n. 2
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;
    }
Esempio n. 3
0
 private static void PlayModeChanged(UnityEditor.PlayModeStateChange mode)
 {
     if (mode == UnityEditor.PlayModeStateChange.EnteredEditMode)
     {
         AkWwiseProjectInfo.Populate();
         AkWwiseFileWatcher.Instance.StartWatchers();
     }
 }
Esempio n. 4
0
    public void OnGUI()
    {
        using (new UnityEngine.GUILayout.HorizontalScope("box"))
        {
            AkWwiseProjectInfo.GetData().autoPopulateEnabled =
                UnityEngine.GUILayout.Toggle(AkWwiseProjectInfo.GetData().autoPopulateEnabled, "Auto populate");

            if (AkWwiseProjectInfo.GetData().autoPopulateEnabled&& AkUtilities.IsWwiseProjectAvailable)
            {
                AkWwiseWWUBuilder.StartWWUWatcher();
            }
            else
            {
                AkWwiseWWUBuilder.StopWWUWatcher();
            }
            UnityEngine.GUILayout.FlexibleSpace();
            if (UnityEngine.GUILayout.Button("Refresh Project", UnityEngine.GUILayout.Width(200)))
            {
                treeView.SaveExpansionStatus();
                if (AkWwiseProjectInfo.Populate())
                {
                    PopulateTreeview();
                }
            }

            if (UnityEngine.GUILayout.Button("Generate SoundBanks", UnityEngine.GUILayout.Width(200)))
            {
                if (AkUtilities.IsSoundbankGenerationAvailable())
                {
                    AkUtilities.GenerateSoundbanks();
                }
                else
                {
                    string errorMessage;

#if UNITY_EDITOR_WIN
                    errorMessage =
                        "Access to Wwise is required to generate the SoundBanks. Please select the Wwise Windows Installation Path from the Edit > Wwise Settings... menu.";
#elif UNITY_EDITOR_OSX
                    errorMessage =
                        "Access to Wwise is required to generate the SoundBanks. Please select the Wwise Application from the Edit > Wwise Settings... menu.";
#endif

                    UnityEngine.Debug.LogError(errorMessage);
                }
            }
        }

        UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);

        treeView.DisplayTreeView(AK.Wwise.TreeView.TreeViewControl.DisplayTypes.USE_SCROLL_VIEW);

        if (UnityEngine.GUI.changed && AkUtilities.IsWwiseProjectAvailable)
        {
            UnityEditor.EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        }
        // TODO: RTP Parameters List
    }
    public void OnGUI()
    {
        GUILayout.BeginHorizontal("Box");

        AkWwiseProjectInfo.GetData().autoPopulateEnabled = GUILayout.Toggle(AkWwiseProjectInfo.GetData().autoPopulateEnabled, "Auto populate");

        if (AkWwiseProjectInfo.GetData().autoPopulateEnabled&& WwiseProjectFound)
        {
            AkWwiseWWUBuilder.StartWWUWatcher();
        }
        else
        {
            AkWwiseWWUBuilder.StopWWUWatcher();
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Refresh Project", GUILayout.Width(200)))
        {
            treeView.SaveExpansionStatus();
            if (AkWwiseProjectInfo.Populate())
            {
                PopulateTreeview();
            }
        }

        if (GUILayout.Button("Generate SoundBanks", GUILayout.Width(200)))
        {
            if (AkUtilities.IsSoundbankGenerationAvailable())
            {
                AkUtilities.GenerateSoundbanks();
            }
            else
            {
                string errorMessage;

#if UNITY_EDITOR_WIN
                errorMessage = "Access to Wwise is required to generate the SoundBanks. Please select the Wwise Windows Installation Path from the Edit > Wwise Settings... menu.";
#elif UNITY_EDITOR_OSX
                errorMessage = "Access to Wwise is required to generate the SoundBanks. Please select the Wwise Application from the Edit > Wwise Settings... menu.";
#endif

                Debug.LogError(errorMessage);
            }
        }

        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        treeView.DisplayTreeView(TreeViewControl.DisplayTypes.USE_SCROLL_VIEW);

        if (GUI.changed && WwiseProjectFound)
        {
            EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        }
        // TODO: RTP Parameters List
    }
    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;
        }
    }
Esempio n. 7
0
    public void OnGUI()
    {
        using (new UnityEngine.GUILayout.HorizontalScope("box"))
        {
            AkWwiseProjectInfo.GetData().autoPopulateEnabled =
                UnityEngine.GUILayout.Toggle(AkWwiseProjectInfo.GetData().autoPopulateEnabled, "Auto populate");

            if (AkWwiseProjectInfo.GetData().autoPopulateEnabled&& AkUtilities.IsWwiseProjectAvailable)
            {
                AkWwiseWWUBuilder.StartWWUWatcher();
            }
            else
            {
                AkWwiseWWUBuilder.StopWWUWatcher();
            }
            UnityEngine.GUILayout.FlexibleSpace();
            if (UnityEngine.GUILayout.Button("Refresh Project", UnityEngine.GUILayout.Width(200)))
            {
                treeView.SaveExpansionStatus();
                if (AkWwiseProjectInfo.Populate())
                {
                    PopulateTreeview();
                }
            }

            if (UnityEngine.GUILayout.Button("Generate SoundBanks", UnityEngine.GUILayout.Width(200)))
            {
                if (AkUtilities.IsSoundbankGenerationAvailable())
                {
                    AkUtilities.GenerateSoundbanks();
                }
                else
                {
                    UnityEngine.Debug.LogError("Access to Wwise is required to generate the SoundBanks. Please go to Edit > Project Settings... and set the Wwise Application Path found in the Wwise Editor view.");
                }
            }
        }

        UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);

        treeView.DisplayTreeView(AK.Wwise.TreeView.TreeViewControl.DisplayTypes.USE_SCROLL_VIEW);

        if (UnityEngine.GUI.changed && AkUtilities.IsWwiseProjectAvailable)
        {
            UnityEditor.EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        }
    }
Esempio n. 8
0
    public void OnGUI()
    {
        AkWwiseProjectInfo.DataSourceType ds;
        var buttonWidth = 150;

        using (new UnityEngine.GUILayout.HorizontalScope("box"))
        {
            ds = (AkWwiseProjectInfo.DataSourceType)UnityEditor.EditorGUILayout.EnumPopup(
                AkWwiseProjectInfo.GetData().currentDataSource, UnityEngine.GUILayout.Width(buttonWidth));
            UnityEngine.GUILayout.Space(5);

            var projectData = AkWwiseProjectInfo.GetData();

            if (ds != projectData.currentDataSource)
            {
                projectData.currentDataSource = ds;
                m_treeView.SetDataSource(AkWwiseProjectInfo.GetTreeData());
            }

            if (ds == AkWwiseProjectInfo.DataSourceType.FileSystem)
            {
                projectData.autoPopulateEnabled =
                    UnityEngine.GUILayout.Toggle(projectData.autoPopulateEnabled, "Auto populate");
            }
            else
            {
                projectData.AutoSyncSelection =
                    UnityEngine.GUILayout.Toggle(projectData.AutoSyncSelection, "Autosync selection");
                AkWwiseProjectInfo.WaapiPickerData.AutoSyncSelection = projectData.AutoSyncSelection;
            }

            UnityEngine.GUILayout.FlexibleSpace();

            if (UnityEngine.GUILayout.Button("Refresh Project", UnityEngine.GUILayout.Width(buttonWidth)))
            {
                if (ds == AkWwiseProjectInfo.DataSourceType.FileSystem)
                {
                    AkWwiseProjectInfo.Populate();
                }
                Refresh();
            }


            if (UnityEngine.GUILayout.Button("Generate SoundBanks", UnityEngine.GUILayout.Width(buttonWidth)))
            {
                if (AkUtilities.IsSoundbankGenerationAvailable())
                {
                    AkUtilities.GenerateSoundbanks();
                }
                else
                {
                    UnityEngine.Debug.LogError("Access to Wwise is required to generate the SoundBanks. Please go to Edit > Project Settings... and set the Wwise Application Path found in the Wwise Editor view.");
                }
            }

            if (projectData.autoPopulateEnabled && AkUtilities.IsWwiseProjectAvailable)
            {
                AkWwiseWWUBuilder.StartWWUWatcher();
            }
            else
            {
                AkWwiseWWUBuilder.StopWWUWatcher();
            }
        }

        using (new UnityEngine.GUILayout.HorizontalScope("box"))
        {
            var search_width = System.Math.Max(position.width / 3, buttonWidth * 2);

            if (ds == AkWwiseProjectInfo.DataSourceType.FileSystem)
            {
                m_treeView.StoredSearchString = m_SearchField.OnGUI(UnityEngine.GUILayoutUtility.GetRect(search_width, 20), m_treeView.StoredSearchString);
                UnityEngine.GUILayout.FlexibleSpace();
            }

            else
            {
                m_treeView.StoredSearchString = m_SearchField.OnGUI(UnityEngine.GUILayoutUtility.GetRect(search_width, 20), m_treeView.StoredSearchString);
                UnityEngine.GUILayout.FlexibleSpace();

                var labelStyle = new UnityEngine.GUIStyle();
                labelStyle.richText = true;
                UnityEngine.GUILayout.Label(AkWaapiUtilities.GetStatusString(), labelStyle);
            }
        }

        UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);


        UnityEngine.GUILayout.FlexibleSpace();
        UnityEngine.Rect lastRect = UnityEngine.GUILayoutUtility.GetLastRect();
        m_treeView.OnGUI(new UnityEngine.Rect(lastRect.x, lastRect.y, position.width, lastRect.height));

        if (UnityEngine.GUI.changed && AkUtilities.IsWwiseProjectAvailable)
        {
            UnityEditor.EditorUtility.SetDirty(AkWwiseProjectInfo.GetData());
        }
    }
    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();
    }
Esempio n. 10
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);
        }
    }
Esempio n. 11
0
    // 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);
    }
Esempio n. 12
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();
    }