juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.14k stars 523 forks source link

Only the first user interaction (touch) goes to Unity #519

Open EskAere opened 2 years ago

EskAere commented 2 years ago

Describe the bug Once Unity is loaded, only the first touch is provided to Unity. I've setup response from Unity to make sure of it.

Expected behavior I want user inputs to be received and handled by the Unity Game.

Unity (please complete the following information):

Smartphone (please complete the following information):

Additional context As you can see here, the first touch is logged, but following touches are only for Flutter.

D/ViewRootImpl@60258c9[MainActivity](18223): ViewPostIme pointer 0 D/ViewRootImpl@60258c9[MainActivity](18223): ViewPostIme pointer 1 I/Unity (18223): Touch at position : (0.0, 0.0) I/Unity (18223): InputManager:StartTouch(CallbackContext) I/Unity (18223): System.Action1:Invoke(T) I/Unity (18223): UnityEngine.InputSystem.Utilities.DelegateHelpers:InvokeCallbacksSafe(CallbackArray1&, TValue, String, Object) I/Unity (18223): UnityEngine.InputSystem.InputActionState:CallActionListeners(Int32, InputActionMap, InputActionPhase, CallbackArray1&, String) I/Unity (18223): UnityEngine.InputSystem.InputActionState:ChangePhaseOfActionInternal(Int32, TriggerState, InputActionPhase, TriggerState&) I/Unity (18223): UnityEngine.InputSystem.InputActionState:ChangePhaseOfAction(InputActionPhase, TriggerState&, InputActionPhase) I/Unity (18223): UnityEngine.InputSystem.InputActionState:ChangePhaseOfInteraction(InputActionPhase, TriggerState&, InputActionPhase, Boolean) I/Unity (18223): UnityEngine.InputSystem.InputActionState:ProcessInteractions(TriggerState&, Int32, Int32) I/Unity (18223): UnityEngine.InputSystem.InputActionState:ProcessControlStateChange(Int32, Int32, Int32, Double, InputEventPtr) I/Unity (18223): UnityEngine.InputSystem.InputManager:FireStateChangeNotifications(Int32, Double, InputEvent) I/Unity (18223): UnityEngine.InputSystem.Inpu I/flutter (18223): Received message from unity: Screen Position : (0.0, 0.0, 0.3) /// World Position : (-3.0, -5.0, 0.0) D/ViewRootImpl@60258c9MainActivity: ViewPostIme pointer 0 D/ViewRootImpl@60258c9MainActivity: ViewPostIme pointer 1 D/ViewRootImpl@60258c9MainActivity: ViewPostIme pointer 0 `

cc-setwo commented 2 years ago

Hello, I have similar issue using new unity input system. I have tried to downgrade to old one and it worked for me.

ChaosVan commented 2 years ago

https://docs.unity3d.com/Packages/com.unity.inputsystem@1.3/manual/Touch.html

You should not use Touchscreen for polling. If you want to read out touches similar to UnityEngine.Input.touches, see EnhancedTouch. If you read out touch state from Touchscreen directly inside of the Update or FixedUpdate methods, your app will miss changes in touch state.