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). このリストは、Unityで可能な内容の一部しか表示していません。ただしトリガーシステムは拡張可能で、Integrationコード自体を修正する必要もありません。
新しいトリガーを追加するには、AkTriggerBaseから派生するC#クラスを書くだけです。AkTriggerBaseから派生するクラスは全て、反射で見つけられ"Trigger On"ドロップリストに追加されます。このクラスにデリゲート(代理)であるtriggerDelegate(GameObject in_target)が含まれ、トリガー条件が発生した時にこれをコールする必要があります。"target"オブジェクトは必須ではなく、現在はColliderと使う時にコライドするオブジェクトを提供するために使用されます。これにより、WwiseコンポーネントがイベントをColliderに対してではなくコライドの対象にPostできます。
もちろん必須ではありませんが、このシステムを利用してゲームコードからオーディオコンポーネントをトリガーすることもできます。トリガー条件が発生するたびに、コードから GetComponent<YourTriggerClass>()
.triggerDelegate(GameObject in_target) をコールさせる(またはカスタム化したファンクションを設定する)だけです。
| 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)
{
triggerDelegate(null);
}
}
}
From your game code, you could have this code:
if (playerIsShot)
{
GetComponent<TriggerOnGunHit>().Hit();
}
これでTriggerOnGunHitトリガーにリンクされたWwiseコンポーネントは全て、自分の責任を果たせます。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 Unity Integrationに対してMon Jan 8 10:46:17 2018に生成されました。
1.6.3