社区问答

欢迎来到 Audiokinetic 社区问答论坛。在此,Wwise 和 Strata 用户可互帮互助。如需我们团队直接提供协助,请前往技术支持申请单页面。若要报告问题,请在 Audiokinetic Launcher 中选择“报告错误”选项(注意,问答论坛并不会接收错误报告)。我们内部设有专门的错误报告系统,会有专人查看报告并设法解决问题。

要想尽快得到满意的解答,请在提问时注意以下几点:

  • 描述尽量具体:比如,想达到什么样的目的,或者具体哪里有问题。
  • 包含关键细节:比如,Wwise 和游戏引擎版本以及所用操作系统等等。
  • 阐明所做努力:阐明自己为了排除故障都采取了哪些措施。
  • 聚焦问题本身:聚焦于问题本身的相关技术细节,以便别人可以快速找到解决方案。

+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.
...