menu
 

在 Audiokinetic 社区问答论坛上,用户可对 Wwise 和 Strata 相关问题进行提问和解答。如需从 Audiokinetic 技术支持团队获取答复,请务必使用技术支持申请单页面。

+1 投票

Hey, I'm experimenting with waapi to get a better understanding of its features and find its use in my day to day development. So far I've been successful in integrating it as an engine API and retrieving items selected in Wwise authoring and subscribing to authoring onSelectionChanged events. Unfortunately I cannot find a way to push a ui command back to wwise authoring using the waapi. Regardless of what I try, it always results in std::future throwing exceptions regarding the results of the attempted action. Since there's no example of passing such a command through waapi in the sample waapi client, I've been trying and failing to make it work for me, but to no result.

Could you give me an example of how a ui command can be passed?

Here's how I'm attempting to get this done:

AkJson args(AkJson::Map
{
    {
        "command", AkVariant("FindInProjectExplorerNoSyncGroup")
    },
    {
        "objects", AkJson::Array
        {
            AkVariant( (std::string)GUID.AsChar() ),
        },
    }
});
m_waapiConnectionClient->Call( ak::wwise::ui::commands::execute, args, AkJson( AkJson::Map() ), AkJson( AkJson::Map() ) );
I've also tried a variant with passing in a reference for the results map, but the result was the same.
I would appreciate an example of using this functionality. Thanks!
分类:General Discussion | 用户: Adrian Jakubiak (140 分)

1个回答

0 投票
 
已采纳

Here is the example to do what you need:
https://gist.github.com/decasteljau/00aa842b6985aefc2e3772c7aad00ce8

(make sure you pass an uninitialized AkJson variable as the result, as the result object is also being used for errors)

 

using namespace AK::WwiseAuthoringAPI;

void PrintApiError(const char* in_functionName, AkJson in_json)
{
    std::cout << "Failed to call '" << in_functionName << "' with error: " << std::string(RapidJsonUtils::GetAkJsonString(in_json)) << std::endl;
}

void HelloWorld()
{
    Client client;

    // Connect to Wwise Authoring on localhost.
    if (!client.Connect("127.0.0.1", 8080))
    {
        std::cout << "Could not connect to Wwise Authoring on localhost." << std::endl;
        return;
    }

    AkJson selectedResult;
    if (!client.Call(ak::wwise::ui::getSelectedObjects, AkJson::Map{}, AkJson::Map{}, selectedResult))
    {
        PrintApiError(ak::wwise::ui::getSelectedObjects, selectedResult);
        return;
    }

    if (selectedResult["objects"].GetArray().size() >= 1)
    {
        AkJson args(AkJson::Map
        {
            { "command", AkVariant("FindInProjectExplorerNoSyncGroup") },
            { "objects", AkJson::Array{
                selectedResult["objects"].GetArray()[0]["id"] } }
        });
        AkJson executeResult;
        if (!client.Call(ak::wwise::ui::commands::execute, args, AkJson(AkJson::Map()), executeResult))
        {
            PrintApiError(ak::wwise::ui::commands::execute, executeResult);
            return;
        }
    }
}
用户: Bernard R. (Audiokinetic) (35.8k 分)
修改于 用户:Bernard R. (Audiokinetic)
Thanks a lot for a quick response! Turned out my code worked just fine - I compiled it today and it's all good. I will mark this as an answer, hopefully somebody else will find this interesting when they struggle to get command passing to work.
...