mirror of
https://github.com/tym1116/BH3.git
synced 2025-12-16 16:34:41 +01:00
59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using UnityEngine;
|
|
|
|
[AddComponentMenu("Wwise/AkEvent")]
|
|
public class AkEvent : AkUnityEventHandler
|
|
{
|
|
public int eventID;
|
|
|
|
public GameObject soundEmitterObject;
|
|
|
|
public bool enableActionOnEvent;
|
|
|
|
public AkActionOnEventType actionOnEventType;
|
|
|
|
public AkCurveInterpolation curveInterpolation = AkCurveInterpolation.AkCurveInterpolation_Linear;
|
|
|
|
public float transitionDuration;
|
|
|
|
public AkEventCallbackData m_callbackData;
|
|
|
|
private void Callback(object in_cookie, AkCallbackType in_type, object in_info)
|
|
{
|
|
for (int i = 0; i < m_callbackData.callbackFunc.Count; i++)
|
|
{
|
|
if (((uint)in_type & (uint)m_callbackData.callbackFlags[i]) != 0 && m_callbackData.callbackGameObj[i] != null)
|
|
{
|
|
AkEventCallbackMsg akEventCallbackMsg = new AkEventCallbackMsg
|
|
{
|
|
type = in_type,
|
|
sender = base.gameObject,
|
|
info = in_info
|
|
};
|
|
m_callbackData.callbackGameObj[i].SendMessage(m_callbackData.callbackFunc[i], akEventCallbackMsg);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void HandleEvent(GameObject in_gameObject)
|
|
{
|
|
GameObject in_gameObjectID = (soundEmitterObject = ((!useOtherObject || !(in_gameObject != null)) ? base.gameObject : in_gameObject));
|
|
if (enableActionOnEvent)
|
|
{
|
|
AkSoundEngine.ExecuteActionOnEvent((uint)eventID, actionOnEventType, in_gameObjectID, (int)transitionDuration * 1000, curveInterpolation);
|
|
}
|
|
else if (m_callbackData != null)
|
|
{
|
|
AkSoundEngine.PostEvent((uint)eventID, in_gameObjectID, (uint)m_callbackData.uFlags, Callback, null, 0u, null, 0u);
|
|
}
|
|
else
|
|
{
|
|
AkSoundEngine.PostEvent((uint)eventID, in_gameObjectID);
|
|
}
|
|
}
|
|
|
|
public void Stop(int _transitionDuration, AkCurveInterpolation _curveInterpolation = AkCurveInterpolation.AkCurveInterpolation_Linear)
|
|
{
|
|
AkSoundEngine.ExecuteActionOnEvent((uint)eventID, AkActionOnEventType.AkActionOnEventType_Stop, soundEmitterObject, _transitionDuration, _curveInterpolation);
|
|
}
|
|
}
|