Search Unity

In build for UWP C# with IL2CPP, not working Input.GetKey and Input.GetKeyDown(Up)

Discussion in 'Windows' started by xsenobyte, Jul 28, 2021.

  1. xsenobyte

    xsenobyte

    Joined:
    Jul 28, 2021
    Posts:
    3
    We have UWP project with integrated with a Unity IL2CPP built as in example https://github.com/TautvydasZilys/unity-uwp-il2cpp-with-csharp-project-example
    On page with unity SwapChainPanel call:

    Code (CSharp):
    1. AppCallbacks appCallbacks = AppCallbacks.Instance;
    2. appCallbacks.SetSwapChainPanel(GetSwapChainPanel());
    3. appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow);
    4. appCallbacks.InitializeD3DXAML();
    Mouse interaction works fine Input.mousePosition and Input.GetMouseButton. But is user click on UWP UserControl or Button or any other UWP ui element unity Input.GetKey and Input.GetKeyDown(Up) stop working. At the same time, the Input.GetMouseButton continue to work as expected.

    Can anyone tell me how to solve issue like this?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    What is "Input Source" set to in the player settings (it's in publishing section IIRC)? Try changing to a different one.
     
  3. xsenobyte

    xsenobyte

    Joined:
    Jul 28, 2021
    Posts:
    3
    By the default "Input Source" have "Core Window" value. I try build with other parametr values. If selected "Swap Chain Panel" it still work incorrect like with "Core Window" value. With "Independent Input Source" Input mouse and all GetKey(Down)(Up) functions not work at all.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you report a bug on this? I don't think this is a known issue.
     
  5. xsenobyte

    xsenobyte

    Joined:
    Jul 28, 2021
    Posts:
    3
    We cannot reproduce full set of bugs on test project, but issue with "Input" that stop working after click to any UWP UI Element even if Input Source set to "Independent Input Source"

    Bug number #1357272
     
    Last edited by a moderator: Aug 13, 2021
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Thanks, we'll take a look.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Looking at the code, it could be this is by design (not 100% sure at this point). It seems we don't want to steal key events from XAML controls if they're focused as otherwise you'll be duplicated inputs for instance if you have a textbox in your app.

    Does the input start working once you click on Unity player portion of the screen again?