Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to use font awesome in UIToolkit?

Discussion in 'UI Toolkit' started by whiteclouds2016, Apr 9, 2021.

  1. whiteclouds2016

    whiteclouds2016

    Joined:
    Sep 22, 2017
    Posts:
    18
    When I use "-unity-font-definition" property to set the TMP Font Asset, the unity editor log error that:
    error: Unsupported type TMP_FontAsset for asset at path 'xxxx'
    only Font, FontAsset, Sprite, Texture2D and VectorImage are supported
    Suggestion: verify the import settings of this asset.

    Any way can do this?
     
  2. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    733
    Can you confirm you are using either the UI Toolkit package on 2020.2 or 2021.1, or using 2021.2?

    If yes, you need to create a Font Asset, not TMP Font Asset. TMP exists as its own package and the type of assets are not shared (yet). But they have the same properties / functionality.
     
    Ufol likes this.
  3. giuliano-marinelli

    giuliano-marinelli

    Joined:
    Mar 3, 2013
    Posts:
    3
    First download the fonts OTF files (https://fontawesome.com/download):
    upload_2022-11-12_3-34-37.png

    Import OTF files in Unity:
    upload_2022-11-12_3-38-40.png

    Create /Text / Font Asset over the OTF files:
    upload_2022-11-12_3-37-48.png

    At the UI Builder. Inside Text style, select both the OTF font and the Font Asset of the fonts type you want.
    Then to use the icons you have to write the hexadecimal unicode of the correspondent icon (it can be found at https://fontawesome.com/search).
    Note: If the unicode has less of 4 chars, add zeros at left of hex chars.
    upload_2022-11-12_3-40-14.png

    That's all.
    Cheers.
     

    Attached Files:

    cichy3000 and HugoBD-Unity like this.
  4. coladeu

    coladeu

    Joined:
    Nov 1, 2022
    Posts:
    2
    Is just me or It works only with just some basic icons?