Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

MouseMove too rare? Or a long drawing?

Discussion in 'UI Toolkit' started by Devi-User, Oct 27, 2018.

  1. Devi-User


    Apr 30, 2016
    I noticed that MouseMove doesn't work enough often (visually), as it really is needed. I caught this situation several times in different code and it looks awful and hurts the eyes. Perhaps my perception is distorted, but it seems to me that with a large number of elements on the screen it works even less often.
    P.S. Perhaps I do not understand how to handle such situations correctly and I should do something like redrawing on my own. Please tell me if this is so.
    So, for example, I have a simple code in my manipulator.

    Code (CSharp):
    2. public class TestManipulator : Manipulator
    3. {
    4.     public VisualElement element;
    6.     protected override void RegisterCallbacksOnTarget()
    7.     {
    8.         element = new VisualElement
    9.         {
    10.             style = {width = 4f, height = 4f, backgroundColor =}
    11.         };
    12.         target.Add(element);
    13.         target.RegisterCallback<MouseMoveEvent>(e =>
    14.         {
    15.    = PositionType.Absolute;
    16.    = e.localMousePosition.x;
    17.    = e.localMousePosition.y;
    18.         });
    19.     }
    20. }
    It just shows the red dot exactly under the cursor. However, this is not always the case. Very often comes across something like this:
    upload_2018-10-27_8-54-30.png upload_2018-10-27_8-54-46.png

    I easily reproduce this effect even in Unity examples. Pay attention to the yellow circle, the cursor is pressed in the same position. And I move the object quite a bit.
    upload_2018-10-27_8-59-3.png upload_2018-10-27_8-59-40.png

    I know that this may not seem critical enough, but my eyes cannot stop seeing this, I just see how the element goes smoothly and then may not keep pace with the cursor and as a result moves unevenly.
    When the elements get quite a bit more and they are a little more complicated, then I can find points in which I see such a result every second frame of my gif. In fact, they are much more, just gif is written with a rather low frequency.
    In general, this creates the feeling that there is some noticeable delay between MouseMove and drawing.

    element.MarkDirtyRepaint() does not help solve the situation

    Attached Files:

    Last edited: Oct 27, 2018
  2. uDamian


    Unity Technologies

    Dec 11, 2017
  3. Devi-User


    Apr 30, 2016
    nope sorry
    I can publish them with a bad description and without a project, just giving a link to the forum
    Last edited: Nov 19, 2018