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 Changing text field caret

Discussion in 'UI Toolkit' started by SkywardRoy, Mar 5, 2021.

  1. SkywardRoy

    SkywardRoy

    Joined:
    Jan 14, 2017
    Posts:
    22
    I figured out how to change the caret color using uss code and now I think the caret is too small. Is there a way to change the size?

    Also, the cursor disappears based on the number of characters that are in my textfield, is this a known issue?
    Untitled 2.png
    The caret is at the end of the characters in both cases
     
    Last edited: Mar 5, 2021
  2. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    740
    Just curious how you did this? Thanks!
     
  3. SkywardRoy

    SkywardRoy

    Joined:
    Jan 14, 2017
    Posts:
    22
    Sure, here is the code I use:
    Code (uss):
    1.  #CommandInput #unity-text-input {
    2.     --unity-cursor-color: rgb(255, 255, 255);
    3. }
    My TextField has a name/id: #CommandInput and then I use the #unity-text-input id to specifically target the element inside the TextField that you can't change without uss.
     
  4. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    740
    Thank you!
     
    SkywardRoy likes this.