- Home /
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.
Answer by Yury-Habets · Oct 29, 2014 at 01:57 PM
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.
Answer by Shups91 · Jan 23, 2013 at 12:10 AM
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 :(
Your answer
![](https://koobas.hobune.stream/wayback/20220613091427im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problem in android java plugin 0 Answers
Send message to Java Code (without a plugin)? 1 Answer
How do you access a custom Java class from Unity? 1 Answer
Calling static jar function from Unity3D 0 Answers
Compass java plugin for Unity Android 4 Answers