Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

OnScreenControl SendValueToControl does nothing

Discussion in 'Input System' started by adsamcik, Sep 26, 2020.

  1. adsamcik

    adsamcik

    Joined:
    Jan 13, 2013
    Posts:
    37
    Edit: Fix in the post below.

    I have been quite frustrated with this. Everything works fine in the test project, but it does not in my own. I have ran into a wall where basically I am looking at my own input, which is correct, but SendValueToControl just does not.

    I am trying to send events from virtual joystick to Gamepad/leftStick. For the control path I use attribute
    [InputControl(layout = "Vector2")] which should ensure the mapping is correct in the inspector. Also if I disable my script the gamepad device disappears (from the debugger) so there it looks ok. I check the value I send to SendValueToControl and it is definitely not 0, 0, but in inspector I see absolutely no events triggered and left stick value at 0. I have no idea what to try next, cause I tried everything I could think of.

    At one point I subscribed to the global event listener and it seemed that there were no events at all generated by the SendValueToControl. Also if I send integer to it, it correctly recognizes that its not the right value.

    There are no errors in the console.

    Also I have tested everything with actual gamepad and it works just fine.

    Any idea would be greatly appreaciated.
     
    Last edited: Sep 26, 2020
  2. adsamcik

    adsamcik

    Joined:
    Jan 13, 2013
    Posts:
    37
    So I figured out how to workaround the problem. I use the new UI Toolkit and when calling SendValueToControl from the UI events (RegisterCallback) the events do nothing, no error, nothing. But if I just save the value and instead call SendValueToControl in an update it registers events just fine and everyting works.

    It should generate error if it needs to be called at a specific time and specific thread.

    I have seen somewhere that it is not yet compatible with UI Toolkit to perhaps this will get fixed with the compatibility update.
     
  3. dreamCirno

    dreamCirno

    Joined:
    May 16, 2018
    Posts:
    20