UnitySendMessage does not work from non-single activity

I am developing an Android plugin that has to start another action (with a user interface and everything ...). This action (which is not inherited from UnityPlayerActivity, of course) should send a message to Unity C # code. I am trying to call UnityPlayer.UnitySendMessage . I see my log a minute before sending a message, but the C # side does not receive it (no exception was thrown).

This is a callback called from another action:

@Override
public void generatePayload() {
   try {
      Log.v(TAG, "generatePayload was triggered");
      UnityPlayer.UnitySendMessage("AndroidObject", "generatePayloadMessage", "");
   } catch (Exception ex) {
      Log.e(TAG, "failed to send message to unity");
   }
}
  • I tried to call this method from the primary unity activity, and the message was successfully received on the unity side.
  • I also tried sending a message from another action (as it should), but in the main thread, and it also did not work ...

? , UnityActivity ? - ?

+4
1

/ , PayLoadMessage ([ ])

UnityPlayer.UnitySendMessage( "AndroidObject", "generatePayloadMessage", "Hello world" );

, Unity .

0

All Articles