PathToGUID doesn't work on iOS64.

Hello, I’m using Unity3d 5.1.4f1 with fmod 1.08.00. In my case, I packed bank files into Assetbundle, and then loaded those banks via FMODUnity.RuntimeManager.StudioSystem.loadBankMemory().

TextAsset masterStringsBank = ab.LoadAsset<TextAsset> ("");
var ret = FMODUnity.RuntimeManager.StudioSystem.loadBankMemory (masterStringsBank.bytes, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bank);
Debug.Log ("ret: " + ret); // ret: OK

TextAsset masterBank = ab.LoadAsset<TextAsset> ("");
ret = FMODUnity.RuntimeManager.StudioSystem.loadBankMemory (masterBank.bytes, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bank);
Debug.Log ("ret: " + ret); // ret: OK

It works well on my Mac and Android. But when I test my project on iPhone 6(iOS 9.2.1), it doesn’t play sounds by PlayOneShot with event name.

FMODUnity.RuntimeManager.PlayOneShot ("event:/fire");

and got:

EventNotFoundException: FMOD Studio event not found 'event:/fire'
  at FMODUnity.OneshotList.SetParameterValue (System.String name, Single value) [0x00000] in <filename unknown>:0 
  at FMODUnity.RuntimeManager.PlayOneShot (System.String path, Vector3 position) [0x00000] in <filename unknown>:0 
  at UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) [0x00000] in <filename unknown>:0 
  at UnityEngine.EventSystems.TouchInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, Boolean pressed, Boolean released) [0x00000] in <filename unknown>:0 
  at UnityEngine.EventSystems.TouchInputModule.ProcessTouchEvents () [0x00000] in <filename unknown>:0 
(Filename: currently not available on il2cpp Line: -1)

And then I try:

var guid = FMODUnity.RuntimeManager.PathToGUID (path);
Debug.Log ("guid: " + guid.ToString ());

and got:

guid: 00000000-0000-0000-0000-000000000000
UnityEngine.EventSystems.TouchInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)

It seems that doesn’t load correctly.

What should I do to make it works?


I would try testing your code with the Mono backend if possible (I know that it’s impossible to submit to the store). 5.1.4 is old and there have been IL2CPP bugs affecting ‘script’ to native library function calls.

You can test if the strings bank is loaded.

    // Right click an event in the tool and select copy GUID
    // {e9b7aafa-2df0-4193-b32e-a74e5753cfa0}
    System.Guid guid = new System.Guid(0xe9b7aafa, 0x2df0, 0x4193, 0Xb3, 0x2e, 0xa7, 0x4e, 0x57, 0x53, 0xcf, 0xa0);
    FMOD.Studio.EventDescription desc;
    FMODUnity.RuntimeManager.StudioSystem.getEventByID(guid, out desc);
    string path;
    desc.getPath(out path);
    Debug.LogFormat("Path = {0}", path);

Path will be empty if the string bank failed to load.

Thanks for your answer. I just tested this code, and I did get empty path. Maybe I should try upgrading unity3d to a newer version.

You can also try modifying fmod_studio.cs so that System.lookupID becomes

    public RESULT lookupID(string path, out Guid guid)
        byte[] rawguid = new byte[16];
        byte[] utf8 = Encoding.UTF8.GetBytes(path + Char.MinValue);
        GCHandle pinnedArray = GCHandle.Alloc(utf8, GCHandleType.Pinned);
        IntPtr pointer = pinnedArray.AddrOfPinnedObject();
        RESULT result =  FMOD_Studio_System_LookupID(rawPtr, pointer, rawguid);
        guid = new Guid(rawguid);
        return result;

and the declaration for System.FMOD_Studio_System_LookupID becomes

    private static extern RESULT FMOD_Studio_System_LookupID(IntPtr studiosystem, IntPtr path, [Out] byte[] guid);

Thanks a lot. But this also doesn’t work for me.

Temporarily, I export GUIDs (File > export GUIDs…) and generate a HashMap that manually mapping event/bus name to guid. And It works:

FMODUnity.RuntimeManager.PlayOneShot (EventToGuid("event:/fire"));

so I don’t need now.

I have upgraded Unity3d to 5.3.4, and the problem solved.