Search Unity

how use background-image field in uss?

Discussion in 'UIElements' started by Devi-User, Nov 19, 2018.

  1. Devi-User

    Devi-User

    Joined:
    Apr 30, 2016
    Posts:
    61
    I put my image in the Resources folder and expected it to be available in uss.
    I tried
    Code (csharp):
    1.  
    2. background-image: img;
    3. background-image: img.png;
    4. background-image: 'img';
    5. background-image: 'img.png';
    6. background-image: "img";
    7. background-image: "img.png";
    8.  
    But it has no effect.

    I get a log message: 'Invalid value for image source String'
    But I have no idea what exactly I can use there, if not String
     
  2. Devi-User

    Devi-User

    Joined:
    Apr 30, 2016
    Posts:
    61
    I apologize. I decided it.
    background-image: url('img.png');
     
  3. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    220
    If you want to use an image from your Resources folder(s), you can also use:
    Code (CSharp):
    1. background-image: resource('img.png');