So, i followed this example and it works in Unity Editor. However, when I build it on Quest 2, it doesn’t play any sound.
I managed sucesfully to play events from bank, but in this case I need to play file from StreamingAssets.
I created empty project and try to make it work, but with no luck.
Callbacks are fired for CREATED, STARTING, CREATE_PROGRAMMER_SOUND , STARTED, DESTROY_PROGRAMMER_SOUND, STOPPED and DESTROYED, yet no sound is playing.
In logcat I get lot of these errrors:
Error DeviceConfig getProperties failed: Permission denial: reading from settings requires:android.permission.READ_DEVICE_CONFIG
Not sure if it is related and it seems app can’t get that permission, at least not in runtime.
Unfortunately, accessing the StreamingAssets folder is not a simple operation on Android:
Accessing streaming assets
On Android and WebGL platforms, it’s not possible to access the streaming asset files directly via file system APIs and streamingAssets path because these platforms return a URL. Use the UnityWebRequest class to access the content instead.
Hey, tnx a lot for fast reply, I missed that somehow. I didn’t figure out right away how to allocate and deallocate those downloaded bytes but I made in-memory copy of it like this:
var data = request.downloadHandler.data;
IntPtr unmanagedPointer = Marshal.AllocHGlobal(data.Length);
Marshal.Copy(data, 0, unmanagedPointer, data.Length);
var eventInstance = RuntimeManager.CreateInstance(eventName);
eventInstance.setUserData(unmanagedPointer);
EVENT_CALLBACK clb = new EVENT_CALLBACK(PlaybackEventCallback);
eventInstance.setCallback(clb);