Search Unity

UI Builder Font complexity

Discussion in 'UI Toolkit' started by marcospgp, Dec 5, 2021.

  1. marcospgp

    marcospgp

    Joined:
    Jun 11, 2018
    Posts:
    194
    The UI Builder is not clear on the distinction between fonts and font assets. Do I have to create a font asset for each font? It seems that setting the font asset to empty (which generated the style `-unity-font-definition: none;`) causes an `Invalid value for font Keyword` warning.

    On top of that, why use absolute url() paths in the generated .uss styles? (`-unity-font: url('/Assets/Main/Terrain/Editor/Fonts/Roboto/Roboto-Regular.ttf');`)
    That's not good for distributed packages, as the location may change. Why not relative paths, or let the user choose? Or better yet, an asset reference!
     
  2. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    324
    In my experience you have indeed to create a Font Asset for each font you want to use in UIToolkit. The purpose of the "-unity-font" style attribute is also questionable for me.

    I also would like to use asset references with Addressables. Paths to assets may change and are not reliable. But I don't know how.
     
  3. seyfe

    seyfe

    Joined:
    May 10, 2019
    Posts:
    74
    Is there any official documentation or comment on this available? Anyone from the Unity team with deeper insights maybe? :)