示例#1
0
    private static string GetWwiseCLI()
    {
        string result = null;

        var settings = WwiseSettings.LoadSettings();

#if UNITY_EDITOR_WIN
        if (!string.IsNullOrEmpty(AudioPluginManagement.DeveloperWwiseInstallationPath))
        {
            result = System.IO.Path.Combine(AudioPluginManagement.DeveloperWwiseInstallationPath, @"Authoring\x64\Release\bin\WwiseCLI.exe");

            if (!System.IO.File.Exists(result))
            {
                result = System.IO.Path.Combine(AudioPluginManagement.DeveloperWwiseInstallationPath, @"Authoring\Win32\Release\bin\WwiseCLI.exe");
            }
        }
#elif UNITY_EDITOR_OSX
        if (!string.IsNullOrEmpty(settings.WwiseInstallationPathMac))
        {
            result = System.IO.Path.Combine(settings.WwiseInstallationPathMac, "Contents/Tools/WwiseCLI.sh");
        }
#endif

        if (result != null && System.IO.File.Exists(result))
        {
            return(result);
        }

        return(null);
    }
示例#2
0
    public static bool Populate()
    {
        try
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode || EditorApplication.isCompiling)
            {
                return(false);
            }

            if (WwiseSetupWizard.Settings.WwiseProjectPath == null)
            {
                WwiseSettings.LoadSettings();
            }

            if (String.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath))
            {
                Debug.LogError("WwiseUnity: Wwise project needed to populate from Work Units. Aborting.");
                return(false);
            }

            s_wwiseProjectPath = Path.GetDirectoryName(AkUtilities.GetFullPath(Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath));
            return(AutoPopulate());
        }
        catch (Exception e)
        {
            Debug.LogError(e.ToString());
            EditorUtility.ClearProgressBar();
        }
        return(true);    //There was an error, assume that we need to refresh.
    }
        public static string GetPath()
        {
            var projectPath          = Path.Combine(Application.dataPath, WwiseSettings.LoadSettings().WwiseProjectPath);
            var wwiseDirectory       = Path.GetDirectoryName(Path.GetFullPath(projectPath));
            var wwiseEventsDirectory = "";
            var dirs = Directory.GetDirectories(wwiseDirectory);

            if (dirs != null)
            {
                for (int i = 0; i < dirs.Length; i++)
                {
                    if (dirs[i].Contains("Events"))
                    {
                        wwiseEventsDirectory = dirs[i];
                        break;
                    }
                }
            }


            string[] files = Directory.GetFiles(wwiseEventsDirectory, "Default Work Unit.wwu", SearchOption.AllDirectories);
            if (files == null)
            {
                return(null);
            }

            return(files[0]);
        }
示例#4
0
    static string GetPlatformBasePathEditor()
    {
        try
        {
            WwiseSettings Settings             = WwiseSettings.LoadSettings();
            string        platformSubDir       = GetPlatformName();
            string        WwiseProjectFullPath = AkUtilities.GetFullPath(Application.dataPath, Settings.WwiseProjectPath);
            string        SoundBankDest        = AkUtilities.GetWwiseSoundBankDestinationFolder(platformSubDir, WwiseProjectFullPath);
            if (Path.GetPathRoot(SoundBankDest) == "")
            {
                // Path is relative, make it full
                SoundBankDest = AkUtilities.GetFullPath(Path.GetDirectoryName(WwiseProjectFullPath), SoundBankDest);
            }

            // Verify if there are banks in there
            DirectoryInfo di         = new DirectoryInfo(SoundBankDest);
            FileInfo[]    foundBanks = di.GetFiles("*.bnk", SearchOption.AllDirectories);
            if (foundBanks.Length == 0)
            {
                SoundBankDest = string.Empty;
            }

            if (!SoundBankDest.Contains(GetPlatformName()))
            {
                Debug.LogWarning("WwiseUnity: The platform SoundBank subfolder does not match your platform name. You will need to create a custom platform name getter for your game. See section \"Using Wwise Custom Platforms in Unity\" of the Wwise Unity integration documentation for more information");
            }

            return(SoundBankDest);
        }
        catch
        {
            return(string.Empty);
        }
    }
示例#5
0
    // Called when changes are made to the scene and when a new scene is created.
    public static void CheckWwiseGlobalExistance()
    {
        WwiseSettings settings        = WwiseSettings.LoadSettings();
        string        activeSceneName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;

        if (String.IsNullOrEmpty(s_CurrentScene) || !s_CurrentScene.Equals(activeSceneName))
        {
            // Look for a game object which has the initializer component
            AkInitializer[] AkInitializers = UnityEngine.Object.FindObjectsOfType(typeof(AkInitializer)) as AkInitializer[];
            if (AkInitializers.Length == 0)
            {
                if (settings.CreateWwiseGlobal == true)
                {
                    //No Wwise object in this scene, create one so that the sound engine is initialized and terminated properly even if the scenes are loaded
                    //in the wrong order.
                    GameObject objWwise = new GameObject("WwiseGlobal");

                    //Attach initializer and terminator components
                    AkInitializer init = objWwise.AddComponent <AkInitializer>();
                    AkWwiseProjectInfo.GetData().CopyInitSettings(init);
                }
            }
            else
            {
                if (settings.CreateWwiseGlobal == false && AkInitializers[0].gameObject.name == "WwiseGlobal")
                {
                    GameObject.DestroyImmediate(AkInitializers[0].gameObject);
                }
                //All scenes will share the same initializer.  So expose the init settings consistently across scenes.
                AkWwiseProjectInfo.GetData().CopyInitSettings(AkInitializers[0]);
            }

            if (Camera.main != null)
            {
                GameObject      mainCameraGameObject = Camera.main.gameObject;
                AkAudioListener akListener           = mainCameraGameObject.GetComponent <AkAudioListener>();

                if (settings.CreateWwiseListener == true)
                {
                    AudioListener listener = mainCameraGameObject.GetComponent <AudioListener>();
                    if (listener != null)
                    {
                        Component.DestroyImmediate(listener);
                    }

                    // Add the AkAudioListener script
                    if (akListener == null)
                    {
                        akListener = mainCameraGameObject.AddComponent <AkAudioListener>();
                        AkGameObj akGameObj = akListener.GetComponent <AkGameObj>();
                        akGameObj.isEnvironmentAware = false;

                        Debug.LogWarning("Automatically added AkAudioListener to Main Camera. Go to \"Edit > Wwise Settings...\" to disable this functionality.");
                    }
                }
            }

            s_CurrentScene = activeSceneName;
        }
    }
示例#6
0
    public static string GetPlatformBasePathEditor()
    {
        try
        {
            WwiseSettings Settings             = WwiseSettings.LoadSettings();
            string        platformSubDir       = Path.DirectorySeparatorChar == '/' ? "Mac" : "Windows";
            string        WwiseProjectFullPath = AkUtilities.GetFullPath(Application.dataPath, Settings.WwiseProjectPath);
            string        SoundBankDest        = AkUtilities.GetWwiseSoundBankDestinationFolder(platformSubDir, WwiseProjectFullPath);
            if (Path.GetPathRoot(SoundBankDest) == "")
            {
                // Path is relative, make it full
                SoundBankDest = AkUtilities.GetFullPath(Path.GetDirectoryName(WwiseProjectFullPath), SoundBankDest);
            }

            // Verify if there are banks in there
            DirectoryInfo di         = new DirectoryInfo(SoundBankDest);
            FileInfo[]    foundBanks = di.GetFiles("*.bnk", SearchOption.AllDirectories);
            if (foundBanks.Length == 0)
            {
                SoundBankDest = string.Empty;
            }

            return(SoundBankDest);
        }
        catch
        {
            return(string.Empty);
        }
    }
示例#7
0
    public static void InitializeWwiseProjectData()
    {
        try
        {
            if (WwiseSetupWizard.Settings.WwiseProjectPath == null)
            {
                WwiseSettings.LoadSettings();
            }

            if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath))
            {
                UnityEngine.Debug.LogError("WwiseUnity: Wwise project needed to populate from Work Units. Aborting.");
                return;
            }

            var fullWwiseProjectPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath);
            s_wwiseProjectPath = System.IO.Path.GetDirectoryName(fullWwiseProjectPath);

            AkUtilities.IsWwiseProjectAvailable = System.IO.File.Exists(fullWwiseProjectPath);
            if (!AkUtilities.IsWwiseProjectAvailable || UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || string.IsNullOrEmpty(s_wwiseProjectPath) ||
                UnityEditor.EditorApplication.isCompiling)
            {
                return;
            }

            var builder = new AkWwiseWWUBuilder();
            builder.GatherModifiedFiles();
            builder.UpdateFiles();
        }
        catch
        {
        }
    }
示例#8
0
    private static string GetWwiseCLI()
    {
        string result = null;

        WwiseSettings settings = WwiseSettings.LoadSettings();

#if UNITY_EDITOR_WIN
        if (!String.IsNullOrEmpty(settings.WwiseInstallationPathWindows))
        {
            result = Path.Combine(settings.WwiseInstallationPathWindows, @"Authoring\x64\Release\bin\WwiseCLI.exe");

            if (!File.Exists(result))
            {
                result = Path.Combine(settings.WwiseInstallationPathWindows, @"Authoring\Win32\Release\bin\WwiseCLI.exe");
            }
        }
#elif UNITY_EDITOR_OSX
        if (!String.IsNullOrEmpty(settings.WwiseInstallationPathMac))
        {
            result = Path.Combine(settings.WwiseInstallationPathMac, "Contents/Tools/WwiseCLI.sh");
        }
#endif

        if (result != null && File.Exists(result))
        {
            return(result);
        }

        return(null);
    }
示例#9
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();
    }
示例#10
0
    // Called when changes are made to the scene and when a new scene is created.
    public static void CheckWwiseGlobalExistance()
    {
        var settings        = WwiseSettings.LoadSettings();
        var activeSceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;

        if (string.IsNullOrEmpty(s_CurrentScene) || !s_CurrentScene.Equals(activeSceneName))
        {
            // Look for a game object which has the initializer component
            var AkInitializers = UnityEngine.Object.FindObjectsOfType <AkInitializer>();
            if (AkInitializers.Length == 0)
            {
                if (settings.CreateWwiseGlobal)
                {
                    //No Wwise object in this scene, create one so that the sound engine is initialized and terminated properly even if the scenes are loaded
                    //in the wrong order.
                    var objWwise = new UnityEngine.GameObject("WwiseGlobal");

                    //Attach initializer and terminator components
                    UnityEditor.Undo.AddComponent <AkInitializer>(objWwise);
                }
            }
            else if (settings.CreateWwiseGlobal == false && AkInitializers[0].gameObject.name == "WwiseGlobal")
            {
                UnityEditor.Undo.DestroyObjectImmediate(AkInitializers[0].gameObject);
            }

            if (settings.CreateWwiseListener)
            {
                AkUtilities.RemoveUnityAudioListenerFromMainCamera();
                AkUtilities.AddAkAudioListenerToMainCamera(true);
            }

            s_CurrentScene = activeSceneName;
        }
    }
示例#11
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;
    }
示例#12
0
    public static System.Collections.Generic.IDictionary <string, string> GetAllBankPaths()
    {
        var Settings             = WwiseSettings.LoadSettings();
        var WwiseProjectFullPath = AudioPluginManagement.DeveloperWwiseProjectPath;

        UpdateSoundbanksDestinationFolders(WwiseProjectFullPath);
        return(s_ProjectBankPaths);
    }
示例#13
0
    static public IDictionary <string, string> GetAllBankPaths()
    {
        WwiseSettings Settings             = WwiseSettings.LoadSettings();
        string        WwiseProjectFullPath = AkUtilities.GetFullPath(Application.dataPath, Settings.WwiseProjectPath);

        UpdateSoundbanksDestinationFolders(WwiseProjectFullPath);
        return(s_ProjectBankPaths);
    }
示例#14
0
    public static System.Collections.Generic.IDictionary <string, string> GetAllBankPaths()
    {
        var Settings             = WwiseSettings.LoadSettings();
        var WwiseProjectFullPath = GetFullPath(UnityEngine.Application.dataPath, Settings.WwiseProjectPath);

        UpdateSoundbanksDestinationFolders(WwiseProjectFullPath);
        return(s_ProjectBankPaths);
    }
示例#15
0
    public static string GetBasePath()
    {
#if UNITY_EDITOR
        return(WwiseSettings.LoadSettings().SoundbankPath);
#else
        return(AkSoundEngineController.Instance.basePath);
#endif
    }
示例#16
0
    public static string GetBasePath()
    {
#if UNITY_EDITOR
        return(WwiseSettings.LoadSettings().SoundbankPath);
#else
        return(ms_Instance.basePath);
#endif
    }
    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;
        }
    }
    public static void SetupSoundbankSetting()
    {
        var WprojPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, WwiseSettings.LoadSettings().WwiseProjectPath);

        AkUtilities.EnableBoolSoundbankSettingInWproj("SoundBankGenerateEstimatedDuration", WprojPath);

        UnityEditor.EditorApplication.update  += RunOnce;
        AkWwiseXMLWatcher.Instance.XMLUpdated += UpdateAllClips;
    }
示例#19
0
    public static bool Populate()
    {
        try
        {
            if (WwiseSetupWizard.Settings.WwiseProjectPath == null)
            {
                WwiseSettings.LoadSettings();
            }

            if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath))
            {
                UnityEngine.Debug.LogError("WwiseUnity: Wwise project needed to populate from Work Units. Aborting.");
                return(false);
            }

            var fullWwiseProjectPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath);
            s_wwiseProjectPath = System.IO.Path.GetDirectoryName(fullWwiseProjectPath);

            AkUtilities.IsWwiseProjectAvailable = System.IO.File.Exists(fullWwiseProjectPath);
            if (!AkUtilities.IsWwiseProjectAvailable || UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || string.IsNullOrEmpty(s_wwiseProjectPath) ||
                UnityEditor.EditorApplication.isCompiling)
            {
                return(false);
            }

            AkPluginActivator.Update();

            var builder = new AkWwiseWWUBuilder();
            if (WwiseObjectReference.migrate == null && !builder.GatherModifiedFiles())
            {
                return(false);
            }

            builder.UpdateFiles();

            if (WwiseObjectReference.migrate != null)
            {
                UpdateWwiseObjectReferenceData();
                PopulateWwiseObjectReferences();

                UnityEditor.AssetDatabase.SaveAssets();

                var currentScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(currentScene);
            }

            return(true);
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError(e.ToString());
            UnityEditor.EditorUtility.ClearProgressBar();
            return(true);
        }
    }
    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;
        }
    }
示例#21
0
 static WwiseSetupWizard()
 {
     try
     {
         Settings = WwiseSettings.LoadSettings();
     }
     catch (Exception e)
     {
         Debug.LogError("WwiseUnity: Failed to load the settings, exception caught: " + e.ToString());
     }
 }
示例#22
0
 static WwiseSetupWizard()
 {
     try
     {
         Settings = WwiseSettings.LoadSettings();
     }
     catch (System.Exception e)
     {
         UnityEngine.Debug.LogError("WwiseUnity: Failed to load the settings, exception caught: " + e);
     }
 }
示例#23
0
    // Generate all the SoundBanks for all the supported platforms in the Wwise project. This effectively calls Wwise for the project
    // that is configured in the UnityWwise integration.
    public static void GenerateSoundbanks()
    {
        WwiseSettings Settings             = WwiseSettings.LoadSettings();
        string        wwiseProjectFullPath = GetFullPath(Application.dataPath, Settings.WwiseProjectPath);

        if (IsSoundbankOverrideEnabled(wwiseProjectFullPath))
        {
            Debug.LogWarning("The SoundBank generation process ignores the SoundBank Settings' Overrides currently enabled in the User settings. The project's SoundBank settings will be used.");
        }

        string wwiseCli = GetWwiseCLI();

        if (wwiseCli == null)
        {
            Debug.LogError("Couldn't locate WwiseCLI, unable to generate SoundBanks.");
            return;
        }

        string command;
        string arguments;

#if UNITY_EDITOR_WIN
        command   = wwiseCli;
        arguments = "";
#elif UNITY_EDITOR_OSX
        command   = "/bin/sh";
        arguments = "\"" + wwiseCli + "\"";
#endif

        arguments += " \"" + wwiseProjectFullPath + "\" -GenerateSoundBanks";

        string output = ExecuteCommandLine(command, arguments);

        bool success = output.Contains("Process completed successfully.");
        bool warning = output.Contains("Process completed with warning");

        string message = "WwiseUnity: SoundBanks generation " + (success ? "successful" : (warning ? "has warning(s)" : "error")) + ":\n" + output;

        if (success)
        {
            Debug.Log(message);
        }
        else if (warning)
        {
            Debug.LogWarning(message);
        }
        else
        {
            Debug.LogError(message);
        }

        AssetDatabase.Refresh();
    }
示例#24
0
    public static bool Populate()
    {
        try
        {
            if (WwiseSetupWizard.Settings.WwiseProjectPath == null)
            {
                WwiseSettings.LoadSettings();
            }

            if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath))
            {
                UnityEngine.Debug.LogError("WwiseUnity: Wwise project needed to populate from Work Units. Aborting.");
                return(false);
            }

            s_wwiseProjectPath = System.IO.Path.GetDirectoryName(AkUtilities.GetFullPath(UnityEngine.Application.dataPath,
                                                                                         WwiseSetupWizard.Settings.WwiseProjectPath));

            if (!System.IO.File.Exists(AkUtilities.GetFullPath(UnityEngine.Application.dataPath,
                                                               WwiseSetupWizard.Settings.WwiseProjectPath)))
            {
                AkWwisePicker.WwiseProjectFound = false;
                return(false);
            }

            AkWwisePicker.WwiseProjectFound = true;

            if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || string.IsNullOrEmpty(s_wwiseProjectPath) ||
                UnityEditor.EditorApplication.isCompiling)
            {
                return(false);
            }

            AkPluginActivator.Update();

            var builder = new AkWwiseWWUBuilder();
            if (!builder.GatherModifiedFiles())
            {
                return(false);
            }

            builder.UpdateFiles();
            return(true);
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError(e.ToString());
            UnityEditor.EditorUtility.ClearProgressBar();
        }

        return(true);        //There was an error, assume that we need to refresh.
    }
示例#25
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();
     }
 }
示例#26
0
    void OnEnable()
    {
        if (string.IsNullOrEmpty(WwiseSettings.LoadSettings().WwiseProjectPath))
        {
            return;
        }

        treeView.SaveExpansionStatus();
        if (AkWwiseWWUBuilder.AutoPopulate())
        {
            PopulateTreeview();
        }
    }
    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
#if UNITY_EDITOR
        WwiseSettings Settings  = WwiseSettings.LoadSettings();
        string        WprojPath = AkUtilities.GetFullPath(Application.dataPath, Settings.WwiseProjectPath);
        AkUtilities.EnableBoolSoundbankSettingInWproj("SoundBankGenerateEstimatedDuration", WprojPath);
#endif
        var playable = ScriptPlayable <AkEventPlayableBehavior> .Create(graph);

        playable.SetInputCount(inputCount);
        setFadeTimes();
        setOwnerClips();
        return(playable);
    }
示例#28
0
    public override UnityEngine.Playables.Playable CreateTrackMixer(UnityEngine.Playables.PlayableGraph graph,
                                                                    UnityEngine.GameObject go, int inputCount)
    {
#if UNITY_EDITOR
        var Settings  = WwiseSettings.LoadSettings();
        var WprojPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, Settings.WwiseProjectPath);
        AkUtilities.EnableBoolSoundbankSettingInWproj("SoundBankGenerateEstimatedDuration", WprojPath);
#endif
        var playable = UnityEngine.Playables.ScriptPlayable <AkEventPlayableBehavior> .Create(graph);

        UnityEngine.Playables.PlayableExtensions.SetInputCount(playable, inputCount);
        setFadeTimes();
        setOwnerClips();
        return(playable);
    }
示例#29
0
    /// <summary>
    ///     Determines the platform base path for use within the Editor.
    /// </summary>
    /// <param name="platformName">The platform name.</param>
    /// <returns>The full path to the sound banks for use within the Editor.</returns>
    public static string GetPlatformBasePathEditor(string platformName)
    {
        var Settings             = WwiseSettings.LoadSettings();
        var WwiseProjectFullPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, Settings.WwiseProjectPath);
        var SoundBankDest        = AkUtilities.GetWwiseSoundBankDestinationFolder(platformName, WwiseProjectFullPath);

        try
        {
            if (System.IO.Path.GetPathRoot(SoundBankDest) == "")
            {
                // Path is relative, make it full
                SoundBankDest = AkUtilities.GetFullPath(System.IO.Path.GetDirectoryName(WwiseProjectFullPath), SoundBankDest);
            }
        }
        catch
        {
            SoundBankDest = string.Empty;
        }

        if (string.IsNullOrEmpty(SoundBankDest))
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: The platform SoundBank subfolder within the Wwise project could not be found.");
        }
        else
        {
            try
            {
                // Verify if there are banks in there
                var di         = new System.IO.DirectoryInfo(SoundBankDest);
                var foundBanks = di.GetFiles("*.bnk", System.IO.SearchOption.AllDirectories);
                if (foundBanks.Length == 0)
                {
                    SoundBankDest = string.Empty;
                }
                else if (!SoundBankDest.Contains(platformName))
                {
                    UnityEngine.Debug.LogWarning(
                        "WwiseUnity: The platform SoundBank subfolder does not match your platform name. You will need to create a custom platform name getter for your game. See section \"Using Wwise Custom Platforms in Unity\" of the Wwise Unity integration documentation for more information");
                }
            }
            catch
            {
                SoundBankDest = string.Empty;
            }
        }

        return(SoundBankDest);
    }
示例#30
0
    // Load the WwiseSettings structure from a serialized XML file
    public static WwiseSettings LoadSettings(bool ForceLoad = false)
    {
        if (s_Instance != null && !ForceLoad)
        {
            return(s_Instance);
        }

        WwiseSettings Settings = new WwiseSettings();

        try
        {
            if (File.Exists(Path.Combine(Application.dataPath, WwiseSettingsFilename)))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(Settings.GetType());
                FileStream    xmlFileStream = new FileStream(Application.dataPath + "/" + WwiseSettingsFilename, FileMode.Open, FileAccess.Read);
                Settings = (WwiseSettings)xmlSerializer.Deserialize(xmlFileStream);
                xmlFileStream.Close();
            }
            else
            {
                string   projectDir         = Path.GetDirectoryName(Application.dataPath);
                string[] foundWwiseProjects = Directory.GetFiles(projectDir, "*.wproj", SearchOption.AllDirectories);

                if (foundWwiseProjects.Length == 0)
                {
                    Settings.WwiseProjectPath = "";
                }
                else
                {
                    // MONO BUG: https://github.com/mono/mono/pull/471
                    // In the editor, Application.dataPath returns <Project Folder>/Assets. There is a bug in
                    // mono for method Uri.GetRelativeUri where if the path ends in a folder, it will
                    // ignore the last part of the path. Thus, we need to add fake depth to get the "real"
                    // relative path.
                    Settings.WwiseProjectPath = AkUtilities.MakeRelativePath(Application.dataPath + "/fake_depth", foundWwiseProjects[0]);
                }

                Settings.SoundbankPath = AkInitializer.c_DefaultBasePath;
            }

            s_Instance = Settings;
        }
        catch (Exception)
        {
        }

        return(Settings);
    }
    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();
        }
    }
示例#32
0
	// Load the WwiseSettings structure from a serialized XML file
	public static WwiseSettings LoadSettings(bool ForceLoad = false)
	{
		if (s_Instance != null && !ForceLoad)
            return s_Instance;
			
		WwiseSettings Settings = new WwiseSettings();
		try
		{
			if (File.Exists(Path.Combine(Application.dataPath, WwiseSettingsFilename)))
			{
				XmlSerializer xmlSerializer = new XmlSerializer(Settings.GetType());
				FileStream xmlFileStream = new FileStream(Application.dataPath + "/" + WwiseSettingsFilename, FileMode.Open, FileAccess.Read);
				Settings = (WwiseSettings)xmlSerializer.Deserialize(xmlFileStream);
				xmlFileStream.Close();
			}
			else
			{
				string projectDir = Path.GetDirectoryName(Application.dataPath);
				string[] foundWwiseProjects = Directory.GetFiles(projectDir, "*.wproj", SearchOption.AllDirectories);
				
				if (foundWwiseProjects.Length == 0)
				{
					Settings.WwiseProjectPath = "";
				}
				else
				{
					// MONO BUG: https://github.com/mono/mono/pull/471
					// In the editor, Application.dataPath returns <Project Folder>/Assets. There is a bug in
					// mono for method Uri.GetRelativeUri where if the path ends in a folder, it will
					// ignore the last part of the path. Thus, we need to add fake depth to get the "real"
					// relative path.
					Settings.WwiseProjectPath = AkUtilities.MakeRelativePath(Application.dataPath + "/fake_depth", foundWwiseProjects[0]);
				}

                Settings.SoundbankPath = AkInitializer.c_DefaultBasePath;
			}
			
			s_Instance = Settings;
		}
		catch (Exception)
		{
		}
		
		return Settings;
	}
示例#33
0
	// Save the WwiseSettings structure to a serialized XML file
	public static void SaveSettings(WwiseSettings Settings)
	{
		try
		{
			XmlDocument xmlDoc = new XmlDocument();
			XmlSerializer xmlSerializer = new XmlSerializer(Settings.GetType());
			using (MemoryStream xmlStream = new MemoryStream())
			{
				StreamWriter streamWriter = new StreamWriter( xmlStream, System.Text.Encoding.UTF8 );
				xmlSerializer.Serialize(streamWriter, Settings);
				xmlStream.Position = 0;
				xmlDoc.Load(xmlStream);
				xmlDoc.Save(Path.Combine(Application.dataPath, WwiseSettingsFilename));
			}
		}
		catch (Exception)
		{
			return;
		}
	}
    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();

    }