AudiokineticのコミュニティQ&AはWwiseやStrataのコミュニティ内でユーザ同士が質問・回答をし合うことができるフォーラムです。Audiokineticテクニカルサポートチームからの回答をご希望の場合は、必ず サポートチケットページ をご利用ください。

Is it possible to pass an Action as a callback when using AkEngine.PostEvent in the Unity integration?

+1 支持
I'm trying to have a callback fire when an event is complete; I can get this to work by passing the Callback() method (seen below) in to PostEvent, but I'd like to be able to pass other delegates in, like the action in the method signature below:

    public override void PlaySound(uint event, GameObject sender, System.Action<object, AkCallbackType, object> callback = null)
    {
        AkSoundEngine.PostEvent(event, sender, (uint)AkCallbackType.AK_EndOfEvent, callback, null);
    }

    private void Callback(object in_cookie, AkCallbackType in_type, object in_callbackInfo)
    {     }

I sort of expected this to work, but I'm getting an error ("cannot convert `System.Action<object,AkCallbackType,object>' expression to type `AkCallbackManager.EventCallback'"). Is this possible? I was unable to find a similar example in the Unity integration demo project, the documentation included in that demo project, or online.

 

edit: Ah, found a solution; you can pass an action in to the constructor for an EventCallback:

AkCallbackManager.EventCallback ec = new AkCallbackManager.EventCallback(new System.Action<object, AkCallbackType, object>((o1,o2,o3) => Debug.Log("Callback")));

AkSoundEngine.PostEvent(eventId, sender, (uint)AkCallbackType.AK_EndOfEvent, ec, null);
Christopher M. (110 ポイント) 2017 1/18 質問 General Discussion
Thanks a lot!

Please sign-in or register to answer this question.

...