Search Unity

Bug Moving objects performance hit

Discussion in 'UI Toolkit' started by b4gn0, Dec 15, 2020.

  1. b4gn0

    b4gn0

    Joined:
    Jul 26, 2019
    Posts:
    119
    Hello,

    since 1.0.0-preview.13 we started seeing performance drop when moving several elements using ".style.left" ".style.top" properties.

    Is there a suggested way to move elements without incurring in such a huge performance drop?

    Here is a profile screenshot with 3 visual elements moving each frame (enemy healthbars):
    upload_2020-12-15_19-12-37.png

    Thank you
     
  2. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    398
    Modifying these style values will invalidate the layout, making this a bit more costly than it needs to be. Try to leave style.top/left at (0,0) and using transform.position instead.
     
  3. Maverick

    Maverick

    Joined:
    Dec 18, 2009
    Posts:
    240
    In my tests using transform.position do not help. Even using usage-hints="DynamicTransform" do not have noticeable impact.

    I did a small test where I move 1000 VisualElements of small size. Fps dropped from 2000 to 50-60.
    So the question is, if UIToolkit should handle 1-2k dynamic elements or this is too much for it?
     
  4. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    1,003
    UI Toolkit should be able to handle thousands of elements moving without a significant performance drop. We've identified a bottleneck with dynamic transforms. We're looking into this.

    Thanks for reporting!
     
    Maverick and b4gn0 like this.