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

Include/import uss files inside uss files

Discussion in 'UI Toolkit' started by cecarlsen, Jul 29, 2019.

  1. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    848
    My USS file is getting quite long. Does USS support includes, like:

    Code (CSharp):
    1. @import url("filename.uss");
    I can't get it working, but I also don't get error messages.

    Perhaps I am using USS in an unintended way, if so do let me know. I found it simplest to import a single file at EditorWindow.OnEnable and add it to the root element instead of specific elements.
     
    Last edited: Jul 30, 2019
  2. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    733
    This feature is not supported and should indeed give you an error, or at least a warning.
     
  3. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    848
    Ok. No warning or error though.
     
  4. felipemullen

    felipemullen

    Joined:
    Mar 4, 2017
    Posts:
    44
    I know this thread is a couple years old, but for anyone coming from the web like myself, and to @cecarlsen if you're still looking:

    You can use multiple stylesheets in a single .uxml definition, like in the image below
    upload_2022-5-12_11-22-44.png

    It may not be your original ask, but there is also a .TSS theme file where you can specify multiple icons and stylesheets to create a theme. I would love to point you to a documentation page on how to use it but I am trying to find out myself in this thread:
    https://forum.unity.com/threads/intended-use-of-theme-style-sheet.1081955/
     
  5. jonathanma_unity

    jonathanma_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    229
    Small update, good news the USS import feature is now supported.
    I'm not entirely sure in which release it was added.
     
  6. razamgar

    razamgar

    Joined:
    Apr 7, 2020
    Posts:
    14
    Great, thanks for the update @jonathanma_unity! I've noticed that there are two ways one can import an USS file into another - @
    import url("filename.uss");
    and @
    import "filename.uss";
    . Is there a reason why one would chose former over the latter, or vice versa?