Merge branch 'fix/touch' into improvements
* fix/touch: Change input source of Flutter touch events so they get handled by Unity.
This commit is contained in:
commit
9cff46cd84
|
@ -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.
|
||||
|
|
Reference in New Issue