Search Unity

Bold Font, 9-Slice, Sorting Order

Discussion in 'UI Toolkit' started by MousePods, Oct 25, 2020.

  1. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Hi,

    I have found several issues.

    1. There is a difference between TMP UGUI and UIToolkit bold with the same font. I don't know if this is a known issue, that its just because SDF isn't implemented yet, or a bug with this font. (see image)
    2. I want to use 9-slice with a SVG but it distorts the SVG and doesn't work. It does work with a png. Is this just not supported atm? If it isn't, will it ever be?
    3. I have a UIToolkit image (a timer) that is on the game screen. I have a regular sprite renderer that covers the screen then shrinks. Now that I switched to UIToolkit, of course the timer is showing above this sprite. Will there ever be support in the future to set the sorting order of the UIDocument so that it can appear behind sprites?
    Thanks!
     

    Attached Files:

  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    1. TMP seems like it uses the shader to expand each letter by an arbitrary amount, as it doesn't space them correctly on some fonts when I use bold on them, I get some letters that overlap. UITK is probably not doing the same thing, I'm not sure what its doing though so I couldn't tell you.

    2. SVG support if very limited right now, I wouldn't expect it to work with 9-slice.

    3. Hopefully in the future they give us the freedom to set its draw layer, right now it's drawn in overlay mode. You can use a RenderTexture in the PanelSettings to render the UI to and then place that on a quad in the scene behind your sprites as a work around.
     
  3. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    1. That make sense! If a Unity Developer reads this, just wondering what they say about it.
    2. That makes sense also. Again, if a Unity Developer read this, just wondering if this will eventually be supported?
    3. Thanks for the work-around! Right now I just left what needs to be hidden as UGUI. Again, if a Unity Developer read this, just wondering if this will eventually be supported
     
  4. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    1,003
    Regarding 1, is it only the color that's different? If so, double-check the color style property that is set on that particular label. That said, SDF font rendering is coming soon.

    For 2, 9-slices on SVGs should work according that:
    • You are using the -unity-slice-* styles
    • You imported your SVG as a "UI Toolkit Vector Image" asset
    If it's not working, can you please provide the SVG asset as well as the USS styles please?

    Also, we are investigating UI order options between uGUI and UI Toolkit.
     
    Chris-Trueman and florianhanke like this.
  5. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Thanks for the reply.
    1. Both labels have the same color, black. When I hit bold for that particular font, it just makes the font a big bigger. (see image)
    2. Yes, the svg is imported correctly (see image). I uploaded a zip with both the png and svg. They are the exactly same image with the same size/slice inline style (see image - the top is the png, the bottom is the svg). I exported them both from affinity designer.
    3. I am sorry. I meant sorting layers between the UI and Sprite Renderers. Right now, at start, I make a sprite renderer cover the entire screen by placing it at z-index of -5 and is on the Foreground Sorting Layer. This covers up the UGUI timer UI. However, with UIToolkit, it is drawn in overlay mode so the timer UI shows overtop my sprite renderer. Will there be a way to say, put it in camera space, and draw the UI on a layer under the foreground layer so the timer hides behind the sprite renderer?
    Thanks! Great work so far on the tool!
     

    Attached Files:

  6. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    1,003
    It really looks like a SDF vs non-SDF font issue. Should be fixed when we support SDF fonts.

    Ok, it looks like a bug. We'll look into it, thanks for reporting.

    Yes, we have plans for a "world space" UI mode, but I can't provide an ETA a this time. When this will be ready, the draw order will basically follow the gameobject hierarchy order.
     
    MousePods likes this.
  7. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Thanks for all the great information!
     
  8. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    1,003
    Sorry to revive this old thread. I just had a double-check at the SVG + 9-slicing issues, and I noticed that the shape was tessellated like so:



    If you look at the top section, the shape is basically "open", which doesn't work well with SVG 9-slices.

    We will try to find a solution to fix this, but in the meantime, you can space out the middle part to force the tessellation to be "closed" at the top section, like so:



    This will work better with SVG slices.
     

    Attached Files:

    MousePods likes this.
  9. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Got it! Thanks for the update. I will look forward to the fix :)
     
  10. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    I don't know if I misunderstood this or I did it right and it just isn't working.

    I had to zip them because I cannot upload a svg.
     

    Attached Files:

  11. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    1,003
    It's really tricky to get right. If you look at "Test 3.zip", I ended up manually splitting the shape in Illustrator to force the generation of new vertices on the sides of the shape.

    In the future, we will be working to do this split automatically to make sure that SVG assets works well with 9-slices.
     

    Attached Files:

    MousePods likes this.
  12. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Really appreciate it, thanks!