Search Unity

Accessing the Stylesheet importer from outside the UIElements namespace

Discussion in 'UI Toolkit' started by BlackclawsK, Oct 15, 2021.

  1. BlackclawsK

    BlackclawsK

    Joined:
    Jan 9, 2019
    Posts:
    100
    The title pretty much says it all, but let me get into details a bit more.

    We have written an .scss importer that creates a Stylesheet asset at the end of the process (calling a sass executable on the host during the import). Since we didn't want the importer to simply write out the result to a new file (which is more like a converter than an importer) we take the result of the sass compiler and pass it directly on to the Stylesheet importer.

    Right now the Stylesheet Importer is an internal class however, so we are accessing it via reflection, which might or might not break in the future. Is there any plan to expose the stylesheet importer interface in some format that is public or is runtime/editor importing of stylesheets from text simply something that is not going to be supported at all (officially)?
     
    SkywardAssembly likes this.
  2. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    331
    It's something we're considering but not planned yet. Most of the use cases we heard so far were runtime related but you provided a great one for Editor and perhaps we could start from there. Taking note of this, thanks for sharing.
     
    SkywardAssembly and BlackclawsK like this.
  3. SkywardAssembly

    SkywardAssembly

    Joined:
    Dec 11, 2022
    Posts:
    4
    We have a similar use case: creating a design system similar to bootstrap or tailwind css from a configuration file (json). Any updates on this?
     
  4. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    There is still no API available for that purpose. However, you might get away with Editor scripts that generate USS files, ask Unity to import them. You would need to check-in some generated USS files though.
     
    SkywardAssembly likes this.