Today I was playing with writing a stylesheet for some editor controls and was playing around with making bootstrap-like classes for reusability. Started with just a very simple .mb-1 class. First thought was to use a variable function to define the base values for a spacer and then scale that depending on the size suffix, same as it is defined in the bootstrap spec. However calc() is not supported so I can’t do something like calc(var(--spacer) * 2). Well that seems simple enough to implement but diving into the code everything related to functions is internal, and now that it is a built-in package I can no longer really edit the source or use an AssemblyReferenceDefinition to access the internals.
Next thought was to make an scss-like pre-processor. Since the StyleSheetImporter reads the file text directly, this means we would need to not only compile into valid uss, but also save that to a file. That is an issue because now you can have changes from both the scss and uss file to resolve since you don’t have a single asset import pipeline.
All this is to say, extending UI Toolkit with a custom function currently seems pretty much impossible. Stronger tools for authoring stylesheets would go a long way to making it faster and easier to use. In general the extensibility of both UI Toolkit and UI Builder are seriously lacking and are the largest hinderance to using them currently. Would really love to see this improved in the future
Generally as of now UI Elements to me still seems a bit half-assed - It would be lovely to get some info on what kind of development is planned for it by Unity.