react-native-unity-view icon indicating copy to clipboard operation
react-native-unity-view copied to clipboard

Keyboard not showing when focusing a text input within Unity

Open CurralesDragon opened this issue 5 years ago • 2 comments

Hi,

I can refer to this same issue: https://github.com/f111fei/react-native-unity-view/issues/140

The keyboard won't show, but if you trigger a keyboard from within react-native before any unity events, it works.

Does anyone have any ideas what the issue is here? Im guessing its some sort of lifecycle event not firing until react-native triggers a keyboard to open.

Thanks

CurralesDragon avatar Sep 21 '20 08:09 CurralesDragon

Hi! Did you encounter this problem in IOS? The situation I encountered in IOS is the same as you. I solved it in the following way. After you start unity, call the following function. I call it through react native

RCT_EXPORT_METHOD(focusInput){
  dispatch_async(dispatch_get_main_queue(), ^{
    UIWindow* window = [[UIApplication sharedApplication].delegate window];
    if (window != nil && window.rootViewController != nil)
    {
        [window makeKeyAndVisible];
    }
  });
}

daijiangping avatar Dec 23 '20 10:12 daijiangping

Yeah the problem was for iOS, I didn’t find a fix but just worked around it.

Thanks very much for posting your fix, Il be sure to give that a go!

CurralesDragon avatar Dec 23 '20 15:12 CurralesDragon