Search Unity

Unity's USS Varible Reference

Discussion in 'UI Toolkit' started by BinaryCats, Dec 15, 2019.

  1. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    Hi,

    I have a TextField, I wish for the background to be transparent until the user hovers over the field.

    I had this working in 2019.2, but since 2019.3 Text Fields (and friends) background are no longer images, but background images.

    2019.2:
    Code (CSharp):
    1. #unity-text-input
    2. {
    3.     background-image: none;
    4. }
    5. :hover>#unity-text-input
    6. {
    7.     background-image: resource("TextField.png");
    8. }
    9. :focus>#unity-text-input
    10. {
    11.     background-image: resource("TextField focused.png");
    12. }
    13.  
    2019.3:
    Code (CSharp):
    1. #unity-text-input
    2. {
    3.     background-color: rgba(0,0,0,0);
    4.     border-color: rgba(0,0,0,0);
    5. }
    6. :hover>#unity-text-input
    7. {
    8.   ??
    9. }
    10. :focus>#unity-text-input
    11. {
    12.   ??
    13. }
    14.  
    I can change the backgrounds colour, so the alpha is 0, which achieves the same effect. However the issue comes when I want to show the background colour again. I could just use the UI Element Debugger, to get the color for both Pro and non-pro themes. But I am curious if I can use the USS Variables Unity Uses to color the background to the desired colour.

    Thanks in advance
     
  2. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    Hi,

    Along with the USS var(...) feature, we will have a public list of Unity-defined styles variables that can be used in your own style rules. Stay tuned for 2020.1!

    In the mean time, I do suggest using values you find with the UIE debugger.

    Sebastien
     
    BinaryCats likes this.
  3. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    That's great new Sebastien!

    I now would like to be cheeky and ask if there are any plans to release the icon default resources paths/names. for example:
    the USS code to get the hamburger:
     background-image:  resource("pane options.png");

    I've literally spent hours of my life using third party tools to find out what Unity Icons are called.

    I'm a firm believer in making my tool UI look like Unity made it (you can take that as a compliment), as it helps the user feel familiar and use it with ease.