GetWwiseSoundBankDestinationFolder() public static method

public static GetWwiseSoundBankDestinationFolder ( string Platform, string WwiseProjectPath ) : string
Platform string
WwiseProjectPath string
return string
Ejemplo n.º 1
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);
        }
    }
Ejemplo n.º 2
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);
        }
    }
Ejemplo n.º 3
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);
    }
    //[MenuItem("File/Build Unity-Wwise Project")]
    public static bool Build()
    {
        //Choose app name and location
        string appPath = EditorUtility.SaveFilePanel("Build Unity-Wwise project",                                                   //window title
                                                     Application.dataPath.Remove(Application.dataPath.LastIndexOf('/')),            //Default app location (unity project root directory)
                                                     "Unity_Wwise_app",                                                             //Default app name
                                                     getPlatFormExtension()                                                         //app extension (depends on target platform)
                                                     );
        //check if the build was cancelled
        bool isUserCancelledBuild = appPath == "";

        if (isUserCancelledBuild)
        {
            UnityEngine.Debug.Log("Wwise: User cancelled the build.");
            return(false);
        }

        //get Wwise project file (.wproj) path
        string wwiseProjFile = Path.Combine(Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath).Replace('/', '\\');

        //get Wwise project root folder path
        string wwiseProjectFolder = wwiseProjFile.Remove(wwiseProjFile.LastIndexOf(Path.DirectorySeparatorChar));

        //get Wwise platform string (the string isn't the same as unity for some platforms)
        string wwisePlatformString = UnityToWwisePlatformString(EditorUserBuildSettings.activeBuildTarget.ToString());

        //get soundbank location in the Wwise project for the current platform target
        string sourceSoundBankFolder = Path.Combine(wwiseProjectFolder, AkUtilities.GetWwiseSoundBankDestinationFolder(wwisePlatformString, wwiseProjFile));

        //get soundbank destination in the Unity project for the current platform target
        string destinationSoundBankFolder = Path.Combine(Application.dataPath + "\\StreamingAssets",                                                                                    //Soundbank must be inside the StreamingAssets folder
                                                         Path.Combine(WwiseSetupWizard.Settings.SoundbankPath, wwisePlatformString)
                                                         );

        //Copy the soundbank from the Wwise project to the unity project (Inside the StreamingAssets folder as defined in Window->Wwise Settings)
        if (!AkUtilities.DirectoryCopy(sourceSoundBankFolder,                               //source folder
                                       destinationSoundBankFolder,                          //destination
                                       true                                                 //copy subfolders
                                       )
            )
        {
            UnityEngine.Debug.LogError("Wwise: The soundbank folder for the " + wwisePlatformString + " platform doesn't exist. Make sure it was generated in your Wwise project");
            return(false);
        }

        //Get all the scenes to build as defined in File->Build Settings
        string[] scenes = new string[EditorBuildSettings.scenes.Length];
        for (int i = 0; i < EditorBuildSettings.scenes.Length; i++)
        {
            scenes[i] = EditorBuildSettings.scenes[i].path;
        }

        //Build the app
        BuildPipeline.BuildPlayer(scenes,                                                               //scenes to build
                                  appPath,                                                              //Location of the app to create
                                  EditorUserBuildSettings.activeBuildTarget,                            //Platform for which to build the app
                                  BuildOptions.None
                                  );

        //Delete the soundbank from the unity project so they dont get copied in the game folder of fututre builds
        Directory.Delete(destinationSoundBankFolder, true);

        return(true);
    }