XCode error on beat callback

Hi FMOD,

I’m having an issue when using the FMOD callback function for iOS. I get the following error:

Unhandled Exception: System.NotSupportedException: IL2CPP does not support marshaling delegates that point to instance methods to native code.
at FMOD.Studio.EventInstance.setCallback (FMOD.Studio.EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask) [0x00000] in :0
UnityEngine.UnhandledExceptionHandler:PrintException(String, Exception)
UnityEngine.UnhandledExceptionHandler:HandleUnhandledException(Object, UnhandledExceptionEventArgs)

The code used in Unity (JS) is as follows and works fine in Unity Editor:
var cb: FMOD.Studio.EVENT_CALLBACK;

[…]

cb = FMOD.Studio.EVENT_CALLBACK(StudioEventCallback);
SlitScore.setCallback(cb, FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_BEAT);

[…]

function StudioEventCallback()
{
// do something
}

Any idea?
Sander

I used the latest integration SDK for Unity BTW.

As the error message says, delegates can’t be instance methods. This is limitation on platforms that use IL2CPP or non-JIT mono.

Use a static method instead (see this Unity tutorial https://unity3d.com/learn/tutorials/topics/scripting/statics)

Our example of a beat callback shows a static method (written in C# though) http://www.fmod.org/documentation/#content/generated/engine_new_unity/script_example_timeline.html