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. Let us know your feedback about the Global Illumination changes in the 2023.2 beta.
    Dismiss Notice
  3. Dismiss Notice

GUI Position Update Delay

Discussion in 'Unity 5 Pre-order Beta' started by joearroyo, Nov 16, 2014.

  1. joearroyo

    joearroyo

    Joined:
    Jan 26, 2014
    Posts:
    10
    We are currently working on moving all our GUI elements away from the legacy GUI and we just finished replacing our in-game cursor image with a canvas.

    There appears to be a fairly large delay on the visual position of the cursor compared to the actual input position of the mouse.

    Every frame, I'm simply setting the RectTransform position of the cursor to the position of the mouse, but even if the game dips slightly under 60fps, the delay becomes very noticeable compared to where the windows mouse cursor is being displayed.

    I've tried my position update code in the following places: Update(), FixedUpdate(), and OnGUI(). However, the delayed result is the same every time.

    Even though we will hide the actual mouse in game, We still feel as though the delay seems unreasonable.

    Is there something about the GUI backend that causes it to only update under certain conditions? Or, has anyone else come across this yet?

    Any help would be greatly appreciated. Thanks!
     
  2. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Wouldn't it be better to use the hardware cursor functionality instead of a canvas sprite? Unless something changed in Unity 5, there's an API for setting the hardware cursor which will have no lag at all.

    Using a sprite will always feel laggy, that's been my experience anyway with older versions of Unity.
     
  3. joearroyo

    joearroyo

    Joined:
    Jan 26, 2014
    Posts:
    10
    Thanks! We were hoping to avoid hardware cursors due to the scale limitations, but it looks like we'll probably just bite the bullet and make it work.