For some players the ui elements are way off if they have large format screen is there a way to fix that?
Scale CUI for players based on screen size?
How are you creating it?
var elements = new CuiElementContainer();
{
var ConfigMenu = elements.Add(new CuiPanel
{
Image = { Color = ColorExtensions.ToRustFormatString(backgroundColor) },
RectTransform = { AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-500 -250", OffsetMax = "500 250", },
CursorEnabled = true }, "Overlay", LayerMain);
elements.Add(new CuiElement
{
Parent = LayerMain, Components = { new CuiRawImageComponent { Png = image, Sprite = "assets/content/textures/generic/fulltransparent.tga" }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" }}
});
var closeThis = new CuiButton
{
Button = { Close = ConfigMenu, Command = $"hardestCarStorage_1 {player.userID}", Color = ColorExtensions.ToRustFormatString(backgroundColor) },
RectTransform = { AnchorMin = configData.settingsUIMain.ExitMin, AnchorMax = configData.settingsUIMain.ExitMax },
Text = { Text = lang.GetMessage("X", this), FontSize = 20, Align = TextAnchor.MiddleCenter }
};Merged post
thats the main window then..
var elements = new CuiElementContainer();
{
var ConfigMenu = elements.Add(new CuiPanel
{
Image = { Color = ColorExtensions.ToRustFormatString(backgroundColor) },
RectTransform = { AnchorMin = "0.28 0.15", AnchorMax = "0.891 0.812" },
CursorEnabled = true }, "Overlay", LayerCarView);
var Header = new CuiLabel
{
Text = { Text = $"<b>{info}</b>", FontSize = 40, Align = TextAnchor.MiddleCenter },
RectTransform ={ AnchorMin = configData.settingsUIMain.HeaderMin, AnchorMax = configData.settingsUIMain.HeaderMax }
};
elements.Add(Header, ConfigMenu);
var RightArrow = new CuiButton
{
Button = { Command = $"hardestCarStorage_Command right {type} {player.userID} {ListPos + 1}", Color = ColorExtensions.ToRustFormatString(backgroundColor) },
RectTransform = { AnchorMin = configData.settingsUIBox.ArrowRightMin,
AnchorMax = configData.settingsUIBox.ArrowRightMax },
Text = { Text = "->", FontSize = 40, Color = ColorExtensions.ToRustFormatString(TextColor), Align = TextAnchor.MiddleCenter}
};
elements.Add(RightArrow, ConfigMenu);
var LeftArrow = new CuiButton
{
Button = { Command = $"hardestCarStorage_Command left {type} {player.userID} {ListPos - 1}", Color = ColorExtensions.ToRustFormatString(backgroundColor) },
RectTransform = { AnchorMin = configData.settingsUIBox.ArrowLeftMin,
AnchorMax = configData.settingsUIBox.ArrowLeftMax },
Text = { Text = "<-", FontSize = 40, Color = ColorExtensions.ToRustFormatString(TextColor), Align = TextAnchor.MiddleCenter }
};
elements.Add(LeftArrow, ConfigMenu); Merged post
Everything i open in the first element seem to be ok but when i add the second ui in that ui there all off. on some screens.
Merged post
I Can post the hole ui code if you need to see the hole thing.
There isn't any native scaling in Rust for the CUI, so the only way to "fix" this would be to offer multiple scaling options per resolution per player as set by each player. There are some plugins that you can integrate with to handle this, which basically asks the player for their resolution, which your plugin can then use to scale accordingly.