Unity AndroidJavaObject pass float array as out parameter

538 Views Asked by At

I have this Java Method

public class Test {
  double calculate(float[] array){
    array[0] = 2.0f;
    return 3.0f;
  }
}

I integrated this Java Method via an Android Archive into Unity. I access this method like this:

var javaObject = new AndroidJavaObject("Test");
float[] inOut = new float[1];
double res = javaObject.Call<double>("calculate", inOut);

Now, the res variable holds the value 3.0f as expected. But the inOut array does still have 0 at index position 0, but it should have 2.0f;

How do I properly pass a primitives array to Java code from Unity and use it as an "inOut" argument?

Thank you

0

There are 0 best solutions below