I’ve been using FMOD Studio for my latest project, and I noticed an odd quirk with the EventInstance::setCallback method. Quick disclaimer, I’m using the C# implementation, so I’m not sure if that changes anything.
Anyway, I noticed that whenever I run the EventInstance::setCallback method in succession, only the latest callback gets assigned, regardless of the callback mask I use. So for example, I wanted a callback/delegate to trigger when an instance is created, and another one to trigger when the instance is stopped. But in this code:
only the EVENT_CALLBACK_TYPE.CREATED callback will register. Conversely, if I switch them around and have the STOPPED callback the last line, only the STOPPED callback will register. The only way I can get this to work is if I get one of those lines of code to be called an update after the other one.
I’m not sure if my implementation is incorrect, or if this is undesired behaviour, but I thought I’d bring it up.
Any insight into this is much appreciated.
There can only be one callback delegate registered per event. If you wish to receive multiple types of events OR them together.
instance.setCallback(m_delegate1, EVENT_CALLBACK_TYPE.STOPPED | EVENT_CALLBACK_TYPE.CREATED);
The specific event that triggered the callback is passed as an argument.