juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there any way to use AndroidJavaObject.Call() function?

Raonshi opened this issue · comments

@juicycleff

Hi. When I making a flutter application with unity, I hot a problem.

My Unity project made by other team (I can not control the unity source code). Also, I have to implement some IPC protocol to communicate unity and flutter. this protocol have to return some value which unity need.

I can't share my code because of security policy. instead, I can share some similar code. like this.

/* Unity Code */
AndroidJavaClass jc = AndroidJavaClass("com.my.flutter.android.module");
stirng result = jc.Call("requestSomeEncodedJson"); // Important line. I have to return the result.
/* Flutter Code */

// This function called by unity
String requestSomeEncodedJson(String param1, int param2) {
  String result = "";
  /* Implements business logic */
  return jsonEncode(result);
}