Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

how use background-image field in uss?

Discussion in 'UI Toolkit' 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:
    873
    If you want to use an image from your Resources folder(s), you can also use:
    Code (CSharp):
    1. background-image: resource('img.png');
     
  4. RobertAcksel

    RobertAcksel

    Joined:
    Sep 20, 2018
    Posts:
    3
    can i use unity internal icons like icons/packagemanager/dark/installed.png?
    What i want to do is something like this below but it will not work...
    Code (CSharp):
    1. .test {
    2.     background-image: url('/icons/packagemanager/dark/installed.png');
    3. }
    4.  
     
    Last edited: May 14, 2020
unityunity