How to create a Custom Scaling Rule Class?

If you go to Project Settings > Engine > User Interface, theres an option which is “DPI Scale Rule” whioch you can set to Custom, and this will set the UI scaling in a kinda default manner whioch im interested in, the other options are trash actually becaus they mess up the UI depending on the screen size and proportions.

So okay i set it to custom and it works absolutely amazing BUT every damned tick i get an error saying the following nonsense: “Project Settings - User Interface Custom Scaling Rule ’ ’ could not be found.” and i investigated and it might render it impossible to package in the future which i dont want. leave me alone please im tired of nonsense errors just lemme dammit set the interface in this way for the sake of god.

Anyway it seems i should create my custom, useful “Custom Scaling Rule Class”, which is an option under the previous one mentioned, which by default is set to none. Oh very useful, set it by default to none so it gives 45921 errors and adding up every tick. Thanks. And by the way if u click the drop down in the None box, theres no hint or anything that wll help u create a “Custom Scaling Rule Class”.

So anyway anyone knows how to create a “Custom Scaling Rule Class” which will probably mess up the perfect but unusable default setting for the UI? Thanks in advance

Simple answer:
You want your DPI Curve to always return 1.0 which will look like a flat horizontal line.
Edit your DPI Curve so it has two points:
Resolution: 0, Scale: 1.0 and Resolution 8000, Scale: 1.0
Set the DPI Scale Rule to Shortest Side, Longest Side, Horizontal, or Vertical. Do not set it to Scale to Fit nor Custom.

Advanced answer:
To create a Custom Scaling Rule Class, make a C++ Class inheriting from UDPICustomScalingRule. Declare an override for GetDPIScaleBasedOnSize(FIntPoint Size) and implement it to return a float representing the DPI Scale. The input parameter named Size should be the current screen resolution (Size.X = Width in pixels, Size.Y = Height in pixels). Take a look at UUserInterfaceSettings::GetDPIScaleBasedOnSize() and UUserInterfaceSettings::CalculateScale() if you want to read the default implementation.

1 Like

I’m not sure you understand what DPI is. If you want your UI to look the same on any resolution, you want to use what you called “trash options”. You want DPI being 1 with your target resolution and scale DPI linear for other resolutions. For example, your target resolution is 4k, and your UI relies on vertical size. So you make sure you have DPI=1 with 4k, DPI=0.5 with 1080p and DPI=2 with 8k. And set rule to “vertical side”.