Hi,
Android version of my game has large assets in StreamingAssets and needs fast random access to them. It turns out to be difficult to achieve since StreamingAssets aren’t exposed as regular files on Android: Unity - Manual: Streaming Assets
Unity suggested workaround is UnityWebRequest, but it’s not designed for random access, not even with a custom downloader.
I decided to just memory-map the assets in Java code and expose them to C# by utilizing code akin to Android-MobileFaceNet-MTCNN-FaceAntiSpoofing/app/src/main/java/com/zwp/mobilefacenet/MyUtil.java at 8e04e44a02b6e6f484b2c852739183e1c953b723 · syaringan357/Android-MobileFaceNet-MTCNN-FaceAntiSpoofing · GitHub
However, lack of AndroidJNI.GetDirectBufferAddress() makes it more complicated. Without it the only thing I have is a java.nio.Buffer object: GetDirectBufferAddress() would be the final step of getting a raw pointer out of it I could use without Java call overhead.
As a workaround I’ll just call JNIEnv::GetDirectBufferAddress() in C++ code instead, but it would be good if that step didn’t require native code in a future Unity version.