初始化工程
| 备注: Python Waapi-Client 专门用于与 Python 3.7+ 一起使用。 |
从任意目录运行以下命令来安装依赖:
# Windows
py -3 -m pip install waapi-client
# macOS, Linux
python3 -m pip install waapi-client
工程代码
该文件包含以下代码,让您能连接到 Wwise Authoring API。
from waapi import WaapiClient, CannotConnectToWaapiException
from pprint import pprint
try:
with WaapiClient() as client:
print("Getting Wwise instance information:")
result = client.call("ak.wwise.core.getInfo")
pprint(result)
print("Query the Default Work Unit information:")
object_get_args = {
"from": {
"path": ["\\Actor-Mixer Hierarchy\\Default Work Unit"]
},
"options": {
"return": ["id", "name", "type"]
}
}
result = client.call("ak.wwise.core.object.get", object_get_args)
pprint(result)
except CannotConnectToWaapiException:
print("Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?")
运行工程
在 Wwise 中打开工程后,使用以下命令在终端上运行脚本:
# Windows
py rpc.py
# macOS, Linux
python3 rpc.py
此时,应会显示如下输出:
Getting Wwise instance information:
[Wwise Information Dictionary dump]
Query the Default Work Unit information:
{'return': [{'id': '{CDF62889-48AA-436C-B7DD-5B6B1DF5050D}',
'name': 'Default Work Unit',
'type': 'WorkUnit'}]}