From b0541d730216963a837d46e35dd2bde2f2d394a0 Mon Sep 17 00:00:00 2001 From: Thomas Stockx Date: Tue, 30 Jul 2019 10:44:09 +0200 Subject: [PATCH] Change input source of Flutter touch events so they get handled by Unity. --- .idea/codeStyles/Project.xml | 29 - .idea/workspace.xml | 695 ------------------ .../flutterunitywidget/UnityView.java | 9 + 3 files changed, 9 insertions(+), 724 deletions(-) delete mode 100644 .idea/codeStyles/Project.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 30aa626..0000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index f3f4a81..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,695 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unityView - UnityUtils - getUnityView - inAppBrowserActivity - onMess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1551719267177 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/android/src/main/java/com/rexraphael/flutterunitywidget/UnityView.java b/android/src/main/java/com/rexraphael/flutterunitywidget/UnityView.java index 1d93c50..0741e89 100644 --- a/android/src/main/java/com/rexraphael/flutterunitywidget/UnityView.java +++ b/android/src/main/java/com/rexraphael/flutterunitywidget/UnityView.java @@ -2,6 +2,8 @@ package com.rexraphael.flutterunitywidget; import android.content.Context; import android.content.res.Configuration; +import android.view.InputDevice; +import android.view.MotionEvent; import android.widget.FrameLayout; import com.unity3d.player.UnityPlayer; @@ -35,6 +37,13 @@ public class UnityView extends FrameLayout { } } + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + ev.setSource(InputDevice.SOURCE_TOUCHSCREEN); + view.injectEvent(ev); + return super.dispatchTouchEvent(ev); + } + @Override protected void onDetachedFromWindow() { // todo: fix more than one unity view, don't add to background.