learntoflutter / flutter_embed_unity

19 stars 5 forks source link

Unity Input field when pressed Makes Keyboard open and suddenly closes automatically #30

Open sultanbuttnarsun opened 2 months ago

sultanbuttnarsun commented 2 months ago

Is there an existing issue for this?

Unity version

Common issues

Flutter version

3.7.10

Description

I am using flutter version 3.7.10 with Dart version 2.19.6, I am encountering an issue regarding keyboard, when my unity app open as widget it shows an input field for user to enter some integer, but when user clicks suddenly keyboard opens and close, it shows in portrait mode in landscape mode tye scret becomes white due to keyboard open close issue, can you confirm that is it due to flutter older version or something due to this unity embed plugin?

Minimum reproducible example (MRE)

Open Unity as Widget and Click on Input Field of Unity for typing any integer 1,2,3 etc.

What platforms are you seeing the problem on?

Android

Devices

Samsung s20 5G

Anything else?

No response

jamesncl commented 2 months ago

Thanks for the bug report. I just tried using an InputField in the example project, using Flutter 3.22.3 and I wasn't able to reproduce the issue:

Screen_Recording_20240910_123612-ezgif com-video-to-gif-converter

So, my best guess is that either it is an issue with Flutter 3.7.10 or there is something else about your project setup which might be causing this.

What I recommend is that you try to reproduce the issue using the example project (there are instructions in the wiki about how to run the examples): add a single InputField to the main scene like I have done above, export the project to the example Flutter project, run it with Flutter 3.7.10, and see what happens with the keyboard. If the problem does not appear, then you know that the problem is not with the Flutter version.

What I suspect may be happening is there is some kind of conflict with input focus. From some brief googling, it seems that the keyboard will automatically close if the input field loses focus. So perhaps that is what is happening - when the input field gains focus when you tap it, something else then causes the focus to be lost, which closes the keyboard. Unfortunately I don't have any further advice, apart from experimenting with the example project until you can get a minimum reproducible example.

Another thing to try would be to see if the same issue occurs with the flutter_unity_widget package

jamesncl commented 2 months ago

To be honest, it might not be the best approach to be using Unity to do the text input due to these focusing problems - this kind of conflict may be a fundamental limitation of using Flutter and Unity together. I suggest you think about doing the text input in Flutter (since this is what it's really good at) and leave Unity just to do 3D rendering.

sultanbuttnarsun commented 2 months ago

Thanks for reply, I will look into it

On Tue, Sep 10, 2024 at 4:53 PM James Allen @.***> wrote:

To be honest, it might not be the best approach to be using Unity to do the text input due to these focusing problems - this kind of conflict may be a fundamental limitation of using Flutter and Unity together. I suggest you think about doing the text input in Flutter (since this is what it's really good at) and leave Unity just to do 3D rendering.

— Reply to this email directly, view it on GitHub https://github.com/learntoflutter/flutter_embed_unity/issues/30#issuecomment-2340457766, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEEYJZQPERY75VKZBBAFLUTZV3MS5AVCNFSM6AAAAABNY2SSIWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBQGQ2TONZWGY . You are receiving this because you authored the thread.Message ID: @.***>