YousicianGit / UnityNativeEdit

Unity Native Input Plugin for both iOS and Android (Unity UI compatible)
44 stars 13 forks source link

Invalid text box position with "Screen Space - Camera" #44

Open eximarus opened 7 years ago

eximarus commented 7 years ago

hello. first of all I want to thank you for your efforts in this amazing plugin. On the android demo project the text appears to be out of screen for me (or at least not inside the textfield). Would be really cool if anyone knows a fix for this.

Hemaolle commented 7 years ago

So you are not seeing the input text at all? Or is it partially visible? Could you post a screenshot?

eximarus commented 7 years ago

it seems to be dependant on the device. on one device I didnt see any text at all, on another the text was slightly outside of the textfield and on the one im using now it looks perfectly fine... the thing is though I didnt change anything. on all devices i just ran the demo project the way it came with the plugin

Hemaolle commented 7 years ago

Sounds interesting. Is it possible that it would be just a UI layout problem in the demo scene? I don't remember hearing about this issue before.

raphac commented 7 years ago

Hello I'm not sure if it is the same problem, but I have a scene, where I can reproduce it (demo, only 30 days available). The problem is on the canvas. When I set the Render Mode to "Screen Space - Camera", the text is outside of the inputfield and very small.

When I change the camera inside of NativeEditBox, the it works for me: Vector3 screenCoord = RectTransformUtility.WorldToScreenPoint(Camera.current, corners[i]); If I don't have a camera, current is null and if I have Canvas Render Mode Screen Spce - Overlay and I have a camera then Camera.current is the main camera: Debug.Log($"Current camera is null: {Camera.current == null}. Current camera is mainCamera: {Camera.main == Camera.current} "); Could that be a solution?

Hemaolle commented 7 years ago

So Screen Space - Overlay worked?

connself commented 7 years ago

When I set the Render Mode to "Screen Space - Camera",Multiple scenes NativeEditBox is always displayed at the top. How to do?

Hemaolle commented 7 years ago

Is it possible for you to use "Screen Space - Overlay" instead?

connself commented 7 years ago

Thank you! I'm try using SetVisible(), I have a question: ios Square keyboard can not enter text.

Hemaolle commented 7 years ago

No problem :)

Please open another issue for the iOS stuff.

raphac commented 7 years ago

So Screen Space - Overlay worked?

Exactly, but when I change to Screen Space - Camera, then it doesn't work correctly, and when I set the Camera.current in the NativeEditBox, it works. But I don't know if there are other problems with this fix.

dongxiansuixin commented 7 years ago

"RectTransformUtility.WorldToScreenPoint" method works with "Screen Space - Overlay" Render Mode, but not works well with "Screen Space - Camera". Just use WorldToScreenPoint method of your camera in the scene instead.

And, if there's any other problem of the plugin, welcome to my clone for solution.