예제 #1
0
    /// <summary>
    /// Tries to communicate with Wwise and compares the current open project with the project path specified in the Unity Wwise Editor settings.
    /// </summary>
    /// <returns>True if the correct wwise project is open in Wwise.</returns>
    private async static Task <bool> CheckProjectLoaded()
    {
        try
        {
            var result = await GetProjectInfo();

            if (result.Count == 0)
            {
                throw new Wamp.ErrorException("Did not get a response from Wwise project");
            }
            var projectInfo = result[0];
#if UNITY_EDITOR_OSX
            var d1 = AkUtilities.ParseOsxPathFromWinePath(projectInfo.filePath);
#else
            var d1 = projectInfo.filePath;
#endif
            var d2 = AkUtilities.GetFullPath(dataPath, AkWwiseEditorSettings.Instance.WwiseProjectPath);
            d1 = d1.Replace("/", "\\");
            d2 = d2.Replace("/", "\\");
            if (d1 != d2)
            {
                ConnectionFailed($"The wrong project({projectInfo.name}) is open in Wwise");
                return(false);
            }
        }

        catch (Wamp.ErrorException e)
        {
            if (e.Json != null)
            {
                ErrorMessage msg = UnityEngine.JsonUtility.FromJson <ErrorMessage>(e.Json);
                if (msg != null)
                {
                    if (msg.message != null)
                    {
                        ErrorMessage = msg.message;
                    }
                }
            }
            if (e.Uri == "ak.wwise.locked")
            {
                return(true);
            }


            ConnectionFailed($"No project is open in Wwise yet");
            return(false);
        }

        return(true);
    }
예제 #2
0
    /// <summary>
    /// Uses a waapi call to get the SoundBank's generated bank path, then opens the containing folder in the system's file browser.
    /// </summary>
    /// <param name="guid">GUID of the object to be found.</param>
    /// <returns>Awaitable Task.</returns>
    private static async Task OpenSoundBankInExplorerAsync(System.Guid guid)
    {
        var args    = new WaqlArgs($"from object \"{guid:B}\"");
        var options = new ReturnOptions(new string[] { "soundbankBnkFilePath" });
        var result  = await WaapiClient.Call([email protected], args, options);

        var ret      = UnityEngine.JsonUtility.FromJson <ReturnWwiseObjects>(result);
        var filePath = ret.@return[0].soundbankBnkFilePath;

#if UNITY_EDITOR_OSX
        filePath = AkUtilities.ParseOsxPathFromWinePath(filePath);
#endif
        UnityEditor.EditorUtility.RevealInFinder(filePath);
    }