Execution HTML5 Error

There is an incompatibility between how C# works on WebGL vs how it works everywhere else. We’ve fixed this issue in our 2.01 branch, however fixing in 2.00 wasn’t possible due to breaking (working behavior) on all other platforms.

To work around this modify fmod.cs, change the signature of DEBUG_CALLBACK to match this:
public delegate RESULT DEBUG_CALLBACK (DEBUG_FLAGS flags, IntPtr file, int line, IntPtr func, IntPtr message);

You’ll note that StringWrapper is replaced with IntPtr.
Replace the callback implementation in RuntimeManager.cs with the following:

[AOT.MonoPInvokeCallback(typeof(FMOD.DEBUG_CALLBACK))]
static FMOD.RESULT DEBUG_CALLBACK(FMOD.DEBUG_FLAGS flags, IntPtr filePtr, int line, IntPtr funcPtr, IntPtr messagePtr)
{
    FMOD.StringWrapper file = new FMOD.StringWrapper(filePtr);
    FMOD.StringWrapper func = new FMOD.StringWrapper(funcPtr);
    FMOD.StringWrapper message = new FMOD.StringWrapper(messagePtr);
    
    if (flags == FMOD.DEBUG_FLAGS.ERROR)
    {
        Debug.LogError(string.Format(("[FMOD] {0} : {1}"), (string)func, (string)message));
    }
    else if (flags == FMOD.DEBUG_FLAGS.WARNING)
    {
        Debug.LogWarning(string.Format(("[FMOD] {0} : {1}"), (string)func, (string)message));
    }
    else if (flags == FMOD.DEBUG_FLAGS.LOG)
    {
        Debug.Log(string.Format(("[FMOD] {0} : {1}"), (string)func, (string)message));
    }
    return FMOD.RESULT.OK;
}

Alternatively don’t use the logging version of HTML5 in Unity.

1 Like