Hello,
I am trying to get an event instance from a START_EVENT_COMMAND callback and then use it later on in managed code to update params/attach it to a transform.
The callback seems to work without complaint, but I’m getting an assert when trying to get the description of this event instance later on:
[FMOD] assert : assertion: 'inst->mHandleBits != 0' failed
Here is how my callback looks:
[AOT.MonoPInvokeCallback(typeof(EVENT_CALLBACK))]
static RESULT HandleCallback(EVENT_CALLBACK_TYPE type, IntPtr instancePtr, IntPtr parameterPtr)
{
FMOD.Studio.EventInstance instance = new FMOD.Studio.EventInstance(instancePtr);
IntPtr callbackInfoPtr;
FMOD.RESULT result = instance.getUserData(out callbackInfoPtr);
if (result != FMOD.RESULT.OK)
{
UnityEngine.Debug.LogError("FMOD Callback error: " + result);
return result;
}
else if(callbackInfoPtr != IntPtr.Zero)
{
GCHandle callbackHandle = GCHandle.FromIntPtr(callbackInfoPtr);
StartEventData callbackInfo = (StartEventData)callbackHandle.Target;
switch (type)
{
case FMOD.Studio.EVENT_CALLBACK_TYPE.START_EVENT_COMMAND:
{
if(parameterPtr != IntPtr.Zero)
{
try
{
FMOD.Studio.EventInstance param = new FMOD.Studio.EventInstance(parameterPtr);
if(param.isValid() && param.hasHandle())
{
callbackInfo.Triggered = 1;
callbackInfo.StartedInstance = new EventInstance(parameterPtr);
}
}
catch(Exception e)
{
UnityEngine.Debug.Log(e);
}
}
}
break;
default:
break;
}
}
return FMOD.RESULT.OK;
}
And here is the call where I get the assert (this happens later down the line in a monobehaviour update where I wait for the “Triggered” to be set to 1):
ignitionCallback.Data.StartedInstance.getDescription(out var desc);
What am I doing wrong? Or is there a different way I should go about updating an instance that was started this way?
If needed I can provide more code than this.
Also, interestingly, using the runtime manager to attach this instance to a gameobject does not produce any errors.
Thank you.