- Home /
AndroidJNI array return
I'm fiddling around with the AndroidJNI-Bridge between Unity and Java. So far, everything is fine (I'm no Java user, so some things to learn on this side), I can call functions and everything. But now I'm stuck with arrays. AndroidJavaObject provides a generic .Call-method, but Unity simply crashes or returns nothing when trying to use that with an array. So I tried the following, but it also crashes and I have no idea why:
ao = new AndroidJavaObject("org/experiments/arrayTest/ArrayReturner");
IntPtr methodID = AndroidJNI.GetMethodID(ao.GetRawClass(), "arrayMethod", "()[F");
IntPtr floatArray = AndroidJNI.CallObjectMethod(ao.GetRawObject(), methodID, null);
float[] f = AndroidJNI.FromFloatArray(floatArray);
Using ao.Call with another method works fine. Thanks for any help!
I can't seem to call any function with it crashing. It's sad that apparently no one here knows anything about JNI and if they do they don't share it...
Your answer
Follow this Question
Related Questions
Java for android script help??? 0 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Need help with script 1 Answer
null texture passed to GUI.DrawTexture 0 Answers