Wwise Demo Game
Demonstration scenes, containing the Wwise Unity Integration, are available to download from the Wwise Launcher Unity page under the contextual menu in the "Recent Unity Projects" title. 这个简单的场景是全部使用 Unity 的标准素材创建的,它演示了如何使用集成的一些基本功能。
安装
The Wwise Demo Game is a standalone project. 它可以在 Wwise Launcher 中下载。您的游戏不能用它作为基础。为此,使用 Wwise Launcher 将 Wwise 集成到一个新的 Unity 工程中。
![]() | 备注:
|
部署
The Wwise Demo Game is intended as a way to preview and show how the Wwise Unity Integration can be used in the Unity Editor.
To deploy one of the Wwise Demo Game scenes to a game console or mobile device, follow these steps:
- Within the Launcher's Unity tab, select the Modify Wwise in Project... option from your Wwise Demo Game Unity Project.
- Launcher 的 Unity 集成页面打开了。
- 添加所需的 Deployment Platforms 并单击 Modify。
- 在 Unity 中打开工程的最新版本。
- 为平台生成 SoundBank。
- Copy the Generated SoundBanks folder to the
StreamingAssets/Audio
folder. - 在 Unity 中,为您想要的平台构建场景然后部署到设备上。
演示场景
这个 First-Person 3D 地图包含一些沿着一条道路的"站点"。For each station, there is a small description on a sign next to the station. 为了便于引用,各个站点的素材都嵌套在场景层级结构中。
脚步演示
步道和第一站演示了如何使用脚本和触发器来创建脚步系统。
在 Wwise 工程中,已经按照推荐的方式实现了脚步:每个表面类型的 Random container,嵌套在一个 Switch Container 下。可以使用 Footstep
事件来发送一个脚步,而表面材料则是用 Footstep_material
切换开关组来控制的。
场景的地形被描绘成四种不同的材质:草、砂石、木头和泥土。在不同的表面上行走会相应地改变脚步的声音。
为了实现这一目标,各个区域都放置了 Box Collider。然后,只需简单地将一个 Switch Value 从 Wwise Picker Window 拖动到一个 Box Collider 上,就设置好了 Footstep_Material
切换开关。为了在 First Person Controller 进入碰撞体时在其上设置切换开关,我们需要在 "AkTriggerEnter" 触发器上触发 Ak Switch 脚本,并确保启用了 "Use Other Object" 复选框(如 Inspector Window 中所示)。
一个非常基本的脚步脚本就实现好了,当玩家走动时,它会每隔 0.3 秒发布一个Footstep
事件。这个脚本已经附加到 First Person Controller 了。以上过程展示了一种通过脚本将事件发布到 Wwise SoundEngine 的方法。
字幕演示
接下来将用这个站点演示如何在 Unity 中创建自定义事件触发器,以及使用事件回调。
一个简单的按钮脚本包含一个指令,当玩家离按钮足够近的时候按下键盘或控制器上的键,该指令就会运行。另一个脚本,AkTriggerButtonPress,会在该指令上注册,然后从它的父类
AkTriggerBase
调用 triggerDelegate。从
AkTriggerBase
继承,可以使自定义触发器在 Wwise Component Inspector 窗口中显示在 "触发器” 列表上(例如,附加在按钮上的 Ak Ambient)。有关自定义触发器的更多信息,请参见 为 Wwise Events 添加新的 Trigger。。
事件开始播放一个包含 WAV marker 的声音文件。注册与事件关联的 marker 回调,可以使得字幕在面板上更新显示。为了实现这一点,在 Ak Ambient 的 inspector 中,勾选了 "Use Callback" 选项。然后,该 GameObject (SubtitleSign)包含一个脚本(
SubtitleDemo.cs),整个被拖放到了
"Game Object" 框中。当回调被触发时会执行 Callback Function(MarkerCallback),它的名称是手动输入的,且
Callback Flag 选为 "Marker"。查看 SubtitleDemo
的代码,可以看到 Callback 函数的实现很简单,就是使用 MarkerCallback
的 uIdentifier
字段作为索引,从预定义的字符串数组中读取字幕。参见 如何与 inspector 一起使用 AkAmbient 以获取更多关于回调的信息。
环境演示
该站点演示了如何对场景的一个区域内所有声音施加效果器。两个洞穴包含一个 EnvironmentZone(同样是用 Box Collider 作为触发器),在这个环境上添加了一条 AuxBus(从 Wwise Picker 窗口中拖放)。
在 Wwise 中,已经创建了两条 Auxiliary Bus,分别包含不同的效果。此外,脚步和 Little Sequence 都选中了 "Use game-defined Auxiliary sends"。
当一个 Wwise 事件从 EnvironmentZone 中发出时,它的声音会连通到该区域关联的 AuxBus。
本站点还演示了 Environment Portal 组件。它可以实现在两个环境之间进行空间过渡。本演示中的三个按钮用于说明 Environment Portal 如何影响 Auxiliary Bus 的混合。
要创建一个环境门户,首先创建一个 Box Collider,它在它的一个轴上连接两个 Ak Environment(在这个演示中,门户会接触到 "z" 轴上的红色区域和蓝色区域)。然后添加 Ak Environment Portal 组件,并选择正确的轴。这两个环境将被混合,并被自动填充。
想了解有关 Environments 和 Environment Portal 的更多信息,请参阅 如何通过 inspector来使用 AkEvironment 和 AkEvironmentPortal(混响区域)。
Timeline Demo
This station demonstrates the use of an AkEventTrack and an AkRTPCTrack within a Timeline in Unity. There are two cubes, which, when the button is pressed, are animated towards each other and stopped when they reach impact.
In order to inspect the Timeline, select Window->Timeline. Then in the Hierarchy, expand the TimelineDemo object, and then expand the Timeline Demo Button object. Then select the Button object. The Timeline editor will now show the Timeline that controls the animation and Wwise Events for the cubes. The Timeline is controlled by the Playable Director component of the Button object.
The Timeline contains two animation tracks, one for each cube. These tracks are used to animate the z position of each cube over time. The Timeline also contains an AkEventTrack and an AkRTPCTrack, marked by a white and red tab, respectively. The AkEventTrack contains two AkEventPlayable clips: the first triggers the PlayCubeMovement Wwise Event, and the next triggers the PlayImpact Wwise Event. The names of these Wwise Events are displayed in the clips. You may need to increase the size of the Timeline editor view and zoom in in order for the name to be displayed correctly. The PlayCubeMovement Wwise Event plays a sine wave source, which has an RTPC affecting its pitch. The name of this RTPC is CubeAcceleration. The AkRTPCTrack increases this RTPC over time as the cubes move towards each other. This causes the pitch of the sine wave to increase, producing a simple sound effect to indicate the acceleration of each cube towards the other.
This station also demonstrates the Motion feature. Note that there is a game object called "Motion listener" in the player hierarchy. This game object set up the output for the Motion device on supported platforms. Any output needs a set of listeners to receive data. That is why the Motion listener also have a Ak Game Object and a Ak Audio Listener. To enable the Motion effect on the cube impact, two important things needs to be done. First, the impact sound needs to be routed to an output bus using the Wwise Motion ShareSet in the Wwise project. Second, the listener used for the Motion output needs to be added to the listeners of the emitter posting the impact event. Inspect the AkMotionListener script for an example on how to add an output.
![]() | 备注: To support the Motion feature on android, the manifest of the application must include the vibration permission. Unity generates automatically the manifest based on the content of the application. Adding a call to Handheld.Vibrate() will add the desired permission in the manifest. |
For more information on the Timeline integration, see Wwise Timeline Integration.
Spatial Audio Scene
This scene is the final product of the Spatial Audio Tutorial.
Generated at Thu Feb 1 09:40:31 2018 for Wwise Unity Integration by
