Description
I have been taking a look at how sending messages from Unity to Flutter works.
AndroidJavaClass jc = new AndroidJavaClass("com.xraph.plugin.flutter_unity_widget.UnityPlayerUtils"); jc.CallStatic("onUnityMessage", message);
We see a new class is created and a method called on it.
The question now is, how expensive is this?
Consider a use case where the Unity partwants to send a message to the Flutter part every single frame as to keep the Flutter UI notified on the current Unity view. E.g. we have a cube in Unity and we want Flutter to display a text above it so we se send the x,y and z coordinates of the cube every single frame.
Is this something that is discouraged?
How much impact would that have?
Would it be a major optimization or a minor optimization to not instantiate a new AndroidJavaClass
every message but rather have only one static instance such that it can be reused?
Is the size of serialiazed message
a contributing factor of performance for communication? (I know it will be for (de)serialization))