Moving and sizing CUI
Hello,
I'm actually trying to make a gui for a phone application. I was wondering if there is any way to size a cui element with pixel instead of the anchors ?
I've seen that the offset is the size in pixel, and anchors are screen relative transforms. (https://umod.org/community/rust/11385-moving-cui-buttonselements -> @2CHEVSKII reply).
I did exactly what he said in the reply : 
         var PhoneGUI = elements.Add(new CuiPanel {
                Image = {
                    Color = "1 1 1 1" 
                }, 
                RectTransform = {
                    AnchorMin = "0.5 0.5", 
                    AnchorMax = "0.6 0.6", 
                    OffsetMax = "-50 -20", // Pixel size?
                    OffsetMin = "50 20" // Pixel size?
                }, 
                CursorEnabled = true, 
                FadeOut = 0.1f }, 
                "Overlay", 
                "Phone");​

And the gui is actually not showing...

I don't really understand how CUI system works...
Thank you for your help, and sorry for my bad english, I'm french :/

Could you show the rest of the code?
Yes sure, but actually I have nothing in, I'm just trying to draw an ui correctly.
There it is :
        public void createPhoneGUI(IPlayer player)
        {
            var bPlayer = BasePlayer.FindByID(Convert.ToUInt64(player.Id));
            var elements = new CuiElementContainer();
            var PhoneGUI = elements.Add(new CuiPanel
            {
                Image = {
                    Color = "1 1 1 1"
                },
                RectTransform = {
                    AnchorMin = "0.5 0.5",
                    AnchorMax = "0.6 0.6",
                    OffsetMax = "-50 -20", // Pixel size?
                    OffsetMin = "50 20" // Pixel size?
                },
                CursorEnabled = true,
                FadeOut = 0.1f
            },
                "Overlay",
                "Phone");
            elements.Add(new CuiButton {
                Button = {
                    Command = "quit",
                    Color = ColorConv(config.colors.hexColors[0]) 
                }, 
                RectTransform = {
                    AnchorMin = $"0.2 0.2",
                    AnchorMax = $"0.2 0.2",
                    OffsetMin = $"15 15",
                    OffsetMax = $"15 15" },
                Text = { Text = "", FontSize = 0 } }, PhoneGUI);
            CuiHelper.AddUi(bPlayer, elements);

        }​
Is it throwing any errors?

Merged post

I tried your code, but removed the "ColorConv" method because I don't have that and it worked.

I got no any error...

Yeah it's a function to convert hex color.

        public static string ColorConv(string hexColor)
        {
            hexColor = hexColor.TrimStart('#');
            if (hexColor.Length != 6 && hexColor.Length != 8)
            {
                hexColor = "000000";
            }
            int red = int.Parse(hexColor.Substring(0, 2), NumberStyles.AllowHexSpecifier);
            int green = int.Parse(hexColor.Substring(2, 2), NumberStyles.AllowHexSpecifier);
            int blue = int.Parse(hexColor.Substring(4, 2), NumberStyles.AllowHexSpecifier);
            int alpha = 255;
            if (hexColor.Length == 8)
            {
                alpha = int.Parse(hexColor.Substring(6, 2), NumberStyles.AllowHexSpecifier);
            }

            return $"{red / 255.0} {green / 255.0} {blue / 255.0} {alpha / 255.0}";
        }

Well this is not working correctly for me... (The ColorConv function is working for me)


Merged post

Okay, I finally re created the plugin, ans it's now working... I don't really know why, I didn't find my error, but it was an error cause by me... Sorry for the inconvenience, ans thanks you @0x89A for your time!