Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

OnScreenControl.SendValueToControl not triggering in Touch.onFingerDown

Discussion in 'Input System' started by Boji, Feb 13, 2021.

  1. Boji

    Boji

    Joined:
    Jul 10, 2012
    Posts:
    44
    Hi,

    I am trying to set a value to the OnScreen Gamepad when a finger is touching the screen.

    For some reason OnScreenControl.SendValueToControl doesn't tigger if I put it in the Touch.onFingerDown event.

    It works if I trigger OnScreenControl.SendValueToControl during Update().

    Is there any way to trigger it during the Touch.onFingerDown event? If I trigger it during Update() it only triggers during the next frame.

    Also is there a way to access the current OnScreen Gamepad the same way I can access Gamepad.current?
    The only way I found to access it is by checking if (gamepad.name == "Gamepad")
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    So, when calling SendValueToControl() from that callback, *no* input gets through on the virtual device? Not even in the next frame?

    My first guess would be its because onFingerDown runs from *within* event processing. The current code doesn't handle queuing from within processing properly. That part I'd consider a bug. Would you mind filing a report with the Unity bug reporter for that one?

    Note that currently, OnScreenControl always has a one frame lag. It puts events on the queue which then gets flushed out in the next frame's update.

    You can get to the device added by OnScreenControls through the control property on the component.

    Code (CSharp):
    1. public OnScreenButton button;
    2.  
    3. void Update()
    4. {
    5.     var device = button.control.device;
     
  3. dreamCirno

    dreamCirno

    Joined:
    May 16, 2018
    Posts:
    20