版本

menu_open
Wwise SDK 2021.1.14
Python (Waapi-Client) – 订阅

初始化工程

备注: Python Waapi-Client 专门用于与 Python 3.6+ 一起使用。

从任意目录运行以下命令来安装依赖:

py -3 -m pip install waapi-client

工程代码

该文件包含以下代码,让您能连接到 Wwise Authoring API。

#!/usr/bin/env python3
from waapi import WaapiClient, CannotConnectToWaapiException
from pprint import pprint
try:
# Connecting to Waapi using default URL
client = WaapiClient()
# NOTE: the client must be manually disconnected when instantiated in the global scope
except CannotConnectToWaapiException:
print("Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?")
else:
# Callback function with a matching signature.
# Signature (*args, **kwargs) matches anything, with results being in kwargs.
def on_name_changed(*args, **kwargs):
obj_type = kwargs.get("object", {}).get("type")
old_name = kwargs.get("oldName")
new_name = kwargs.get("newName")
print("Object '{}' (of type '{}') was renamed to '{}'\n".format(old_name, obj_type, new_name))
client.disconnect()
handler = client.subscribe("ak.wwise.core.object.nameChanged", on_name_changed, {"return": ["type"]})
print("Subscribed 'ak.wwise.core.object.nameChanged', rename an object in Wwise")

运行工程

在 Wwise 中打开工程后,使用以下命令在终端上运行脚本:

py subscribe.py

此时,应会显示如下输出:

Getting Wwise instance information:
Subscribed 'ak.wwise.core.object.nameChanged', rename an object in Wwise

接着,在 Wwise 中重命名对象。此时,应会显示如下输出:

Object 'MySound' (of type 'Sound') was renamed to 'MyOtherSound'

此页面对您是否有帮助?

需要技术支持?

仍有疑问?或者问题?需要更多信息?欢迎联系我们,我们可以提供帮助!

查看我们的“技术支持”页面

介绍一下自己的项目。我们会竭力为您提供帮助。

来注册自己的项目,我们帮您快速入门,不带任何附加条件!

开始 Wwise 之旅