CuiHelper documentation?Solved

I'm not able to find any documentation of the CuiHelper class
Tho I found a little demo on some forum for a while ago but it doesn't seem to actuelly work, nothing happens when the command is executed (no error messages either)

[Command("cui")]
        private void cmdCui(BasePlayer player, string command, string[] args)
        {


            var elements = new CuiElementContainer();

            var mainName = elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.8 0.25",
                    AnchorMax = "0.995 0.8"
                },
                CursorEnabled = true
            });
            var closeButton = new CuiButton
            {
                Button =
                {
                    Close = mainName,
                    Color = "0.8 0.8 0.8 0.2"
                },
                RectTransform =
                {
                    AnchorMin = "0.86 0.92",
                    AnchorMax = "0.97 0.98"
                },
                Text =
                {
                    Text = "X",
                    FontSize = 22,
                    Align = TextAnchor.MiddleCenter
                }
            };
            elements.Add(closeButton, mainName);
            for (var i = 2; i < 10; i++)
            {
                elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text = "hello " + i,
                        FontSize = 18,
                        Align = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.06 {1 - 0.07*i + 0.006}",
                        AnchorMax = $"0.75 {1 - 0.07*(i - 1)}"
                    }
                }, mainName);
                elements.Add(new CuiButton
                {
                    Button =
                    {
                        Command = "cui" + i,
                        Color = "0.8 0.8 0.8 0.2"
                        
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.76 {1 - 0.07*i + 0.006}",
                        AnchorMax = $"0.87 {1 - 0.07*(i - 1)}"
                    },
                    Text =
                    {
                        Text = "+",
                        FontSize = 22,
                        Align = TextAnchor.MiddleCenter
                    }
                }, mainName);
            }
            Puts(elements.ToString());
            CuiHelper.AddUi(player, elements);
            



        }
In response to Wulf ():
There is no documentation for it at the moment, only the source and comments on our GitHub. https://...
Alrighty then. do you've any idea why the exable I showed aboth doesn't work?
In response to TactiTac0z ():
Alrighty then. do you've any idea why the exable I showed aboth doesn't work?
Becaust you didn't set the name for your main element

Merged post

            var mainName = "blablabla";
                
            elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.8 0.25",
                    AnchorMax = "0.995 0.8"
                },
                CursorEnabled = true
            }, "Hud", mainName);

try that

In response to Orange ():
Becaust you didn't set the name for your main element

Merged post

...
ohhh ok, does all elements require a name or is it only the main parent?

Merged post

or more spesificly just panels?
In response to TactiTac0z ():
ohhh ok, does all elements require a name or is it only the main parent?

Merged post
Only elements that are mother for other elements (ex: Main, panel for icons, etc)
In response to Orange ():
Only elements that are mother for other elements (ex: Main, panel for icons, etc)

Alright thanks.

there is an  orther thing, when a collection of cui elements is made
(when a collection of elements is made to show up using: CuiHelper.addUI)
How do I go about removeing them again? I see CuiHelper.RemoveUI is expecting a string input? is that the id of the element or something like that?


Also I've seen some expableds in orther poeples creations how to use the buttons it seems that the only way to use the buttons is that the button class expects a Command field that gets executed when a user press the button. Aren't there a better way of doing that?
it would be smart with a CuiButton.OnPress or something like that in my head that seems to be a little but more senceable

CuiHelper.DestroyUi(player, element name here);
In response to Orange ():
CuiHelper.DestroyUi(player, element name here);
Ohhh so I've to destroy all ui elements one buy one?

Also I tryed to give it a name but still no luck:
[Command("cui")]
        private void cmdCui(BasePlayer player, string command, string[] args)
        {


            var elements = new CuiElementContainer();
            
            

            var mainName = elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.8 0.25",
                    AnchorMax = "0.995 0.8"
                },
                CursorEnabled = true
            }, "Hud", "test");
            var closeButton = new CuiButton
            {
                Button =
                {
                    Close = mainName,
                    Color = "0.8 0.8 0.8 0.2"
                },
                RectTransform =
                {
                    AnchorMin = "0.86 0.92",
                    AnchorMax = "0.97 0.98"
                },
                Text =
                {
                    Text = "X",
                    FontSize = 22,
                    Align = TextAnchor.MiddleCenter
                }
            };
            
            elements.Add(closeButton, mainName);
            for (var i = 2; i < 10; i++)
            {
                elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text = "hello " + i,
                        FontSize = 18,
                        Align = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.06 {1 - 0.07*i + 0.006}",
                        AnchorMax = $"0.75 {1 - 0.07*(i - 1)}"
                    }
                }, mainName);
                elements.Add(new CuiButton
                {
                    Button =
                    {
                        Command = "cui" + i,
                        Color = "0.8 0.8 0.8 0.2"
                        
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.76 {1 - 0.07*i + 0.006}",
                        AnchorMax = $"0.87 {1 - 0.07*(i - 1)}"
                    },
                    Text =
                    {
                        Text = "+",
                        FontSize = 22,
                        Align = TextAnchor.MiddleCenter
                    }
                }, mainName);
            }
            Puts(elements.ToString());
            CuiHelper.AddUi(player, elements);
            



        }​
In response to TactiTac0z ():
Ohhh so I've to destroy all ui elements one buy one?

Also I tryed to give it a name but s...
Elements depend on their parents, if you destroy (or won't draw) a parent for an element, the element will be destroyed (or won't be drawn)
Take a look at my GodmodeIndicator or PerformanceUI
Alright but it stil doesn't work thho
In response to TactiTac0z ():
Alright but it stil doesn't work thho
Take a look at existing CUI-using plugins (PerformanceUI/GodmodeIndicator from me, or many other). It's really easy to manage things when you got an example in front of your face.

PerformanceUI Seems really complicated and Godmodeindacator plugin only adds a picture. I just want to know how to add a simple label
Witch for somereosn is much harder then it looks giving that CuiLabel doesn't have a constroctor and that the Text field is readonly...
So I'm sorry if this is super obvies for you but I understand nada :P

Maybe you can make a simple exable that just adds a simple Label?

In response to TactiTac0z ():
PerformanceUI Seems really complicated and Godmodeindacator plugin only adds a picture. I just want...
I suggest using cuielement with cuitextcomponent instead of cuilabel, it works better at the end.
Locked automatically