Search Unity

MouseMove too rare? Or a long drawing?

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

  1. Devi-User

    Devi-User

    Joined:
    Apr 30, 2016
    Posts:
    61
    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):
    1.  
    2. public class TestManipulator : Manipulator
    3. {
    4.     public VisualElement element;
    5.  
    6.     protected override void RegisterCallbacksOnTarget()
    7.     {
    8.         element = new VisualElement
    9.         {
    10.             style = {width = 4f, height = 4f, backgroundColor = Color.red}
    11.         };
    12.         target.Add(element);
    13.         target.RegisterCallback<MouseMoveEvent>(e =>
    14.         {
    15.             element.style.positionType = PositionType.Absolute;
    16.             element.style.positionLeft = e.localMousePosition.x;
    17.             element.style.positionTop = e.localMousePosition.y;
    18.         });
    19.     }
    20. }
    21.  
    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.
    https://forum.unity.com/attachments...0/?temp_hash=280a6a7a850b81eb9ab9887310eb6e01
    In general, this creates the feeling that there is some noticeable delay between MouseMove and drawing.

    P.S.
    element.MarkDirtyRepaint() does not help solve the situation
     

    Attached Files:

    Last edited: Oct 27, 2018
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
  3. Devi-User

    Devi-User

    Joined:
    Apr 30, 2016
    Posts:
    61
    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