R
R
Roman Mindiashvili2016-09-12 12:15:34
Unity
Roman Mindiashvili, 2016-09-12 12:15:34

Unity3d AndroidJavaObject.Call how to return data as multidimensional array?

Good afternoon!
I add to the Unity project work with bluetooth on Android.
In Eclipse I write in java:

Set<BluetoothDevice> pairedDevices  = BLAD.getBondedDevices();
                if(pairedDevices.size()>0){
                   String[][] devices =  new String[2][] ;
                   devices[0] = new String[pairedDevices.size()];
                   devices[1] = new String[pairedDevices.size()];
                   for(BluetoothDevice device: pairedDevices){
                          ++k;
                          devices[0][k-1]= device.getName();
                          devices[1][k-1]= device.getAddress();
                   }
                   return devices;
                }
                else{
                   String[][] devices =  new String[1][];       
                   devices[0] = new String[1];
                   devices[0][0]= "";
                   return devices;
                }
        }

In Unity in C # I already use the library function:
public static string[][] GetPairedDevs(){
                if (Application.platform == RuntimePlatform.Android){
                        return BTObj.Call<string[][]>("GetPairedDevices");
                }
                else{
                        string[][] ss = new string[1][];
                        ss[0] = new string[1];
                        ss[0][0] = "111";
                        return ss;
                }
        }

I will also point out the cross:
unity3d.ru/distribution/viewtopic.php?f=5&t=40320
There are no problems when returning a one-dimensional array. I tried two-dimensional and an array of arrays - I can’t see the result in Unity ... (
Someone can tell me how to properly organize data transfer in the form of a multidimensional array?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question