gree / unity-webview

zlib License
2.23k stars 684 forks source link

Lost button input outside of the webview on Android #400

Open Salbrox opened 5 years ago

Salbrox commented 5 years ago

Hi,

When I have a webview on Android I can no longer capture input from keyboard / controller buttons. I need to use up/down/left/right arrows to select buttons in my UI outside of the webview. This works when running in editor on macOS but not on Android.

I added this to the update function but it is not detecting the button presses when the webview is active:

    if (Input.GetKeyDown(KeyCode.LeftArrow))
    {
        Debug.Log("Left Arrow Pressed");
    }

    if (Input.GetKeyDown(KeyCode.RightArrow))
    {
        Debug.Log("Right Arrow Pressed");
    }

    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("Up Arrow Pressed");
    }

    if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("Down Arrow Pressed");
    }
KojiNakamaru commented 5 years ago

On Android/iOS, this plugin simply overlays native webview views over the unity rendering view. If a native webview view is visible and has the focus, the unity rendering view lose it. You might be able to get the focus back for the unity rendering view by tapping any region outside the webview.