버전
menu_open
Wwise Unity Integration Documentation
Adding New Triggers for Wwise Events

In most of Wwise components for Unity, there is a "Trigger On" property from which you can select which Unity notification/event will trigger the Wwise component (Event, Switch, State, etc). This list contain only a subset of what is possible in Unity. However, the triggering system is extensible, without modifying the Integration code itself.

To add a new trigger, you simply have to write a C# class that derives from AkTriggerBase. All classes derived from AkTriggerBase will be found through reflection and added to the "Trigger On" drop list. This class contains a delegate, triggerDelegate(GameObject in_target), that you must call when the conditions for your trigger occur. The "target" object is optional, and currently used to give collided objects when used with Colliders. This allow Wwise components to Post events on the "collidee" instead of the Collider.

While entirely optional, you could use this system to trigger audio components from your game code too. You can simply call GetComponent<YourTriggerClass>().triggerDelegate(GameObject in_target) whenever your trigger condition occur from your code (or have a custom function).

Note: Currently the maximum number of derivative classes of AkTriggerBase is 32.

Here is an example, with a custom function:

public class TriggerOnGunHit : AkTriggerBase
{
void Hit()
{
if(triggerDelegate != null)
{
}
}
}

From your game code, you could have this code:

if (playerIsShot)
{
GetComponent<TriggerOnGunHit>().Hit();
}

Any Wwise component linked to the TriggerOnGunHit trigger would then do its job. Note that in many simple situations, this is completely superfluous; you could also simply call the base Wwise SDK through AkSoundEngine.PostEvent("GunHit", gameObject) and let the sound designer handle the effect of this event in Wwise.


이 페이지가 도움이 되었나요?

지원이 필요하신가요?

질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!

지원 페이지를 방문해 주세요

작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.

프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.

Wwise를 시작해 보세요