Search Unity

USS border-radius not working consistently

Discussion in 'UI Toolkit' started by marcpeyre, Mar 3, 2021.

  1. marcpeyre

    marcpeyre

    Joined:
    Jan 23, 2014
    Posts:
    15
    Hi everyone! I've been using the UIToolkit a lot lately and I must say that I really like how powerful it is for styling editor tools. However I stumbled upon an issue with the border-radius property. Maybe it is an issue on my part but I would like your expertise on how to fix it.

    I have a VisualElement with USS styling of border-radius of 2px to give it rounded corners. However, with different positions or widths of the VisualElement it sometimes cuts off the rounded corners on the right side. It might be hard to see on the screenshot but the left corners are rounded correctly and the right corners are cut off by 2px so it shows up square.



    Here you can see it in motion:



    I'm using VisualElement.transform.position and VisualElement.style.width to control the resizing/repositioning of the VisualElement.

    I'm using Unity 2020.2.0f1
     
  2. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    220
    Indeed, this is something we are aware of, and we have some ongoing work to improve the border rendering process, which should be making its way into 2021.2 or a near future package update.

    In the meantime you can enable MSAA on your EditorWindow by adding the following line in OnEnable or CreateGUI:
    this.SetAntiAliasing(4);