What are Slate Units?

Why does Slate use Slate Units for padding and sizes? What are Slate Units? Are they pixels?

Slate Units are a way for us to make UI that is independent of pixels ( more precisely: independent of the pixel density of your monitor). A brief motivation is needed: building a UI where you specify everything in pixels just wouldn’t work across multiple platforms these days. The size of a pixel and number of pixels packed into a a single square centimeter of a display varies dramatically. Check out this site for some info: http://dpi.lv/.

So, a single Slate Unit does not have a size per-se. By default it was convenient to set it to 1 Slate Unit is 1 pixel. However, if you bring up the widget reflector you can use the App Scale to play with how big you want a single Slate Unit to be. This applies to the entire application (e.g. the whole editor, game, etc.)

Another trick is that we can scale Slate Units dynamically for different parts of the widget hierarchy. This is where things get interesting and somewhat complicated. One example of this is the SNodePanel (it powers Blueprints, Material Editor, and other graph-based UIs.). The SNodePanel scales the SlateUnit to pixel ratio for its own content to make its contents appear bigger or smaller when you zoom in/out.

Finally, we attempt to provide an automated heuristic for scaling your game based on the size of the monitor. Because we do not have reliable information about the pixel density of various platforms we cannot always do the right thing. At the moment we provide a simple setting: a curve function found in Edit->Project Settings->User Interface. You can use that to define how your in-game UIs will scale. For example, a flat line with y == 1 means you always want each Slate Unit to be 1 pixel. If you want your game to be 1:1 at 720p and linearly scale as your window size increases, you can express that by putting a point down a x=720, y=1 and another point at x=1440,y=2. This isn’t perfect, but it seems to be handling the most common cases for now.

4 Likes

so how do you get the current screen size in slate units?
edit: got it!

how is screen size in slate units found

1 Like