Java Plugin : Button added on UnityPlayer Activity -> touch not working

Hi all,

I’m making a binding from Unity to a Java SDK. That Java SDK adds a View (RelativeLayout) to the current Activity (UnityPlayer.currentActivity) with an android.widget.Button in it.

The view is perfectly displayed but when the user touches/tap the button, the OnClickListener.onClick method of the button isn’t called.

The view with the button is added using this code :
UnityPlayer.currentActivity.addContentView(view, params);

I think that Unity probably catches all user touch events.
Is it possible to forward them so that the Button can fire the onClick ?
Is there another way ?

Thanks in advance for your help.

You have two possible solutions here:

  • create a separate window for your view, for example a Dialog;
  • create your own activity which shows your view.

The reason is that UnityPlayerNativeActivity consumes all these events, because the input loop is associated with Unity window.

I tried to add in my Manifest for com.unity3d.player.UnityPlayerNativeActivity :

< meta-data android:name=“unityplayer.ForwardNativeEventsToDalvik” android:value=“true” />

Bu no result so far :frowning: