Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Changing Virtual Mouse Input Position from Script

Discussion in 'Input System' started by Persegan, May 3, 2022.

  1. Persegan

    Persegan

    Joined:
    Feb 12, 2015
    Posts:
    14
    Is there a way to change the position of the pointer of a Virtual Mouse Input component? I'd like to move the grahpics, rect transform and pointer from code to the actual position of my system cursor if I have one.


    I've tried mouseVirtualInput.virtualMouse.WarpCursorPosition(systemMouse.current.position.ReadValue()); but it doesn't seem to do anything.


    I can move the graphics and recttransform portion of it and make them follow my system cursor no problem, but the moment I move the virtual mouse it resets to the last position I left it in, instead of continuing from the system cursor's position.
     
    Last edited: May 3, 2022
  2. Vincent_LKB

    Vincent_LKB

    Joined:
    Apr 15, 2022
    Posts:
    5
    same question~
     
  3. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    Any updates?
     
  4. Vincent_LKB

    Vincent_LKB

    Joined:
    Apr 15, 2022
    Posts:
    5
    use this InputState.Change(m_VirtualMouse.position, position);
     
    Taobao, Evgeno and Ruchir like this.
  5. R_0_V_E_X

    R_0_V_E_X

    Joined:
    Mar 11, 2020
    Posts:
    2
    Thanks! this worked