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

Question Letter spacing for Textfield

Discussion in 'UI Toolkit' started by pnthoai165, Feb 17, 2023.

  1. pnthoai165

    pnthoai165

    Joined:
    Mar 23, 2020
    Posts:
    4
    Hi everyone,

    I wonder that couldn't style apply for letter spacing for textfield input?
    I put the image for my case with child selector to input text element to style the textfield default element.
    upload_2023-2-17_11-13-8.png

    From what I understand is that default textfield element is not label -> cannot apply text spacing style.
    I can customize the textfield using C# script. However, I just want to clear my doubt from the above assumption.

    Faithfully.
     
  2. magnetic_scho

    magnetic_scho

    Joined:
    Feb 2, 2020
    Posts:
    69
    AFAIK letter spacing is not supported for TextField. I implemented a click-to edit functionality with a Label that is then replaced with a TextField. Initially, I had letter spacing on the label, but then the text would always look different in the TextField. I ended up removing the letter spacing from the Label.
     
  3. vejab

    vejab

    Joined:
    Dec 21, 2021
    Posts:
    85
    I think the easiest solution would be to make 4 one-digit labels
     
    Last edited: Feb 24, 2023
  4. pnthoai165

    pnthoai165

    Joined:
    Mar 23, 2020
    Posts:
    4
    Thanks, @magnetic_scho. I was also thinking about that solution if letter spacing is not supported.
     
  5. martinpa_unity

    martinpa_unity

    Unity Technologies

    Joined:
    Oct 18, 2017
    Posts:
    359
    Hi @pnthoai165!

    Which version of Unity are you using? You should be able to use the letter spacing property on the
    TextField
    directly (and not on the input field).

    Hope this helps!
     
    HugoBD-Unity likes this.
  6. magnetic_scho

    magnetic_scho

    Joined:
    Feb 2, 2020
    Posts:
    69
    I'm on 2021.3.16f1 and setting letter-spacing doesn't do anything.
     
  7. pnthoai165

    pnthoai165

    Joined:
    Mar 23, 2020
    Posts:
    4
    Save version and problem with @magnetic_scho
     
  8. HugoBD-Unity

    HugoBD-Unity

    Unity Technologies

    Joined:
    May 14, 2018
    Posts:
    439
    Hi! Can you verify if it works in the gameview ? Prior to 2022.1, the editor text field used a different text engine which did not support letter spacing. You can find more info on the TextField refactor in this forum post.
     
    pnthoai165 likes this.
  9. magnetic_scho

    magnetic_scho

    Joined:
    Feb 2, 2020
    Posts:
    69
    I can confirm, that this works now in 2022.3.