Inheritance: WwiseSetupWindow
Ejemplo n.º 1
0
    private static void ScheduleMigration()
    {
        // TODO: Is delayCall wiped out during a script reload?
        // If not, guard against having a delayCall from a previously loaded code being run after the new loading.

        if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || UnityEditor.EditorApplication.isCompiling)
        {
            // Skip if not in the right mode, wait for the next callback to see if we can proceed then.
            UnityEditor.EditorApplication.delayCall += ScheduleMigration;
            return;
        }

        try
        {
            WwiseSetupWizard.PerformMigration(m_scheduledMigrationStart, m_scheduledMigrationStop);

            // Force the user to return to the launcher to perform the post-installation process if necessary
            if (m_scheduledReturnToLauncher)
            {
                if (UnityEditor.EditorUtility.DisplayDialog("Wwise Migration Successful!",
                                                            "Please close Unity and go back to the Wwise Launcher to complete the installation.", "Quit"))
                {
                    UnityEditor.EditorApplication.Exit(0);
                }
            }
            else
            {
                UnityEditor.EditorApplication.delayCall += RefreshCallback;
            }
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError("WwiseUnity: Error during migration: " + e);
        }
    }
    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;
        }
    }
Ejemplo n.º 3
0
    // Called when changes are made to the scene and when a new scene is created.
    public static void CheckWwiseGlobalExistance()
    {
        var activeSceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;

        if (!string.IsNullOrEmpty(s_CurrentScene) && s_CurrentScene.Equals(activeSceneName))
        {
            return;
        }

        var settings = AkWwiseEditorSettings.Instance;
        // 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
                UnityEditor.Undo.AddComponent <AkInitializer>(objWwise);
            }
        }
        else if (settings.CreateWwiseGlobal == false && AkInitializers[0].gameObject.name == "WwiseGlobal")
        {
            UnityEditor.Undo.DestroyObjectImmediate(AkInitializers[0].gameObject);
        }

#if AK_WWISE_ADDRESSABLES && UNITY_ADDRESSABLES
        var bankHolder = UnityEngine.Object.FindObjectOfType <AK.Wwise.Unity.WwiseAddressables.InitBankHolder>();
        if (bankHolder == null)
        {
            UnityEngine.GameObject wwiseGlobalObject = UnityEngine.GameObject.Find("WwiseGlobal");
            if (wwiseGlobalObject != null)
            {
                bankHolder = UnityEditor.Undo.AddComponent <AK.Wwise.Unity.WwiseAddressables.InitBankHolder>(wwiseGlobalObject);
            }
        }

        if (bankHolder != null && bankHolder.InitBank == null)
        {
            var initBankPath = System.IO.Path.Combine("Assets", settings.GeneratedSoundbanksPath, "Init.asset");
            var initbank     = UnityEditor.AssetDatabase.LoadAssetAtPath <AK.Wwise.Unity.WwiseAddressables.WwiseAddressableSoundBank>(initBankPath);
            bankHolder.InitBank = initbank;
            EditorUtility.SetDirty(bankHolder);
        }
#endif

        if (settings.CreateWwiseListener)
        {
            WwiseSetupWizard.AddAkAudioListenerToMainCamera(true);
        }


        s_CurrentScene = activeSceneName;
    }
    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;
        }
    }
Ejemplo n.º 5
0
 public static void Init()
 {
     // Get existing open window or if none, make a new one:
     Settings = WwiseSettings.LoadSettings();
     if (windowInstance == null)
     {
         windowInstance          = ScriptableObject.CreateInstance <WwiseSetupWizard> ();
         windowInstance.position = new Rect((Screen.currentResolution.width - SETUP_WINDOW_WIDTH) / 2, (Screen.currentResolution.height - SETUP_WINDOW_HEIGHT) / 2, SETUP_WINDOW_WIDTH, SETUP_WINDOW_HEIGHT);
         windowInstance.minSize  = new Vector2(SETUP_WINDOW_WIDTH, SETUP_WINDOW_HEIGHT);
         windowInstance.title    = "Wwise Setup";
         windowInstance.Show();
     }
 }
    public static void Init()
    {
        // Get existing open window or if none, make a new one:
        Settings = WwiseSettings.LoadSettings();
		if( windowInstance == null)
        {
			windowInstance = ScriptableObject.CreateInstance<WwiseSetupWizard> ();
            windowInstance.position = new Rect((Screen.currentResolution.width - SETUP_WINDOW_WIDTH) / 2, (Screen.currentResolution.height - SETUP_WINDOW_HEIGHT) / 2, SETUP_WINDOW_WIDTH, SETUP_WINDOW_HEIGHT);
            windowInstance.minSize = new Vector2(SETUP_WINDOW_WIDTH, SETUP_WINDOW_HEIGHT);
#if !UNITY_5 || UNITY_5_0
            windowInstance.title = "Wwise Setup";
#else
            windowInstance.titleContent = new GUIContent("Wwise Setup");
#endif
            windowInstance.Show();
        }
    }
    public static void OpenDocMac()
    {
        string DestPath = AkUtilities.GetFullPath(Application.dataPath, "..");
        string docPath  = string.Format("{0}/WwiseUnityIntegrationHelp_AppleCommon_en/index.html", DestPath);

        if (!File.Exists(docPath))
        {
            WwiseSetupWizard.UnzipHelp(DestPath);
        }

        if (File.Exists(docPath))
        {
            AkDocHelper.OpenDoc(docPath);
        }
        else
        {
            UnityEngine.Debug.Log("Wwise: Unable to show documentation. Please unzip WwiseUnityIntegrationHelp_AppleCommon_en.zip manually.");
        }
    }
Ejemplo n.º 8
0
    private static void RunSetupImpl()
    {
        try
        {
            Debug.Log("WwiseUnity: Running install setup...");

            AkSceneUtils.CreateNewScene();

            WwiseSetupWizard.Setup();

            Debug.Log("WwiseUnity: Refreshing asset database.");
            AssetDatabase.Refresh();

            Debug.Log("WwiseUnity: End of setup, exiting Unity.");
            EditorApplication.Exit(0);
        }
        catch (Exception e)
        {
            Debug.LogError("WwiseUnity: Exception caught: " + e.ToString());
            EditorApplication.Exit(1);
        }
    }
Ejemplo n.º 9
0
    private static void ScheduleMigration()
    {
        // TODO: Is delayCall wiped out during a script reload?
        // If not, guard against having a delayCall from a previously loaded code being run after the new loading.

        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 += ScheduleMigration;
            return;
        }

        try
        {
            WwiseSetupWizard.PerformMigration(m_scheduledMigrationStart, m_scheduledMigrationStop);
            EditorApplication.delayCall += RefreshCallback;
        }
        catch (Exception e)
        {
            Debug.LogError("WwiseUnity: Error during migration: " + e);
        }
    }
    public static void RunDemoSceneSetup()
    {
        try
        {
            Debug.Log("WwiseUnity: Running demo scene setup...");

            AkSceneUtils.CreateNewScene();

            WwiseSetupWizard.Setup();

            AkSceneUtils.OpenExistingScene("Assets/WwiseDemoScene/WwiseDemoScene.unity");

            Debug.Log("WwiseUnity: Refreshing asset database.");
            AssetDatabase.Refresh();

            Debug.Log("WwiseUnity: End of demo scene setup, exiting Unity.");
            EditorApplication.Exit(0);
        }
        catch (Exception e)
        {
            Debug.LogError("WwiseUnity: Exception caught: " + e.ToString());
            EditorApplication.Exit(1);
        }
    }
Ejemplo n.º 11
0
    static void InstallNewPlatforms()
    {
        try
        {
            // Get a list of installed plugins
            string pluginsPath = Path.Combine(Application.dataPath, "plugins");

            if (!Directory.Exists(pluginsPath))
            {
                Directory.CreateDirectory(pluginsPath);
            }

            DirectoryInfo pluginsDirectory = new DirectoryInfo(pluginsPath);
            FileInfo[]    foundPlugins     = pluginsDirectory.GetFiles("*AkSoundEngine*", SearchOption.AllDirectories);
            List <string> installedPlugins = new List <string>();
            string        ToAdd            = "";
            foreach (FileInfo plugin in foundPlugins)
            {
                if (plugin.DirectoryName.Contains("x86") && plugin.FullName.Contains(".dll"))
                {
                    // x86 and x86_64 plus .dll mean Windows
                    ToAdd = "Windows";
                }
                else if (plugin.DirectoryName.Contains("x86") && plugin.FullName.Contains(".so"))
                {
                    // x86 and x86_64 plus .so mean Windows
                    ToAdd = "Linux";
                }
                else if (plugin.DirectoryName.Contains("Metro"))
                {
                    ToAdd = "Metro";
                }
                else if (plugin.DirectoryName.Contains("PSVita"))
                {
                    ToAdd = "Vita";
                }
                else if (plugin.FullName.Contains(".bundle"))
                {
                    ToAdd = "Mac";
                }
                else if (plugin.FullName.Contains(".xex"))
                {
                    ToAdd = "XBox360";
                }
                else if (plugin.FullName.Contains(".meta") || plugin.FullName.Contains(".def") || plugin.FullName.Contains(".pdb"))
                {
                    continue;
                }
                else
                {
                    ToAdd = Path.GetFileName(plugin.DirectoryName);
                }

                if (!installedPlugins.Contains(ToAdd))
                {
                    installedPlugins.Add(ToAdd);
                }
            }

            // Get the available plugins, and mark the new ones for install
            pluginsPath      = Path.Combine(Path.Combine(Path.Combine(Application.dataPath, "Wwise"), "Deployment"), "Plugins");
            pluginsDirectory = new DirectoryInfo(pluginsPath);
            DirectoryInfo[] availablePlatforms = pluginsDirectory.GetDirectories();



            foreach (DirectoryInfo platform in availablePlatforms)
            {
                if (platform.Name == "Common")
                {
                    continue;
                }

                if (!installedPlugins.Contains(platform.Name))
                {
                    WwiseSetupWizard.InstallPlugin(platform);
                }
            }
        }
        catch
        {
            Debug.Log("WwiseUnity: Unable to install new platform plugins. Please copy them manually to Assets/Plugins");
        }
    }
Ejemplo n.º 12
0
    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();
    }