Hi, I'm not new to programming but I am new to Rust development, and fairly new to C#.
I am adding 2 CUIButtons to a CuiElementContainer, but when I click on them, they a) seem to be merged together (they both depress as being clicked) and b) they pass in the same argument to the ConsoleCommand (I've tested using SendReply).
I've been trying to get to the bottom of this for hours. Any help is appreciated.
Merged post
Sorry @Wulf, any kind of lifeline you can throw me here? I guess having no one come back to me yet means it's not a noobish error, which is at least some comfort.
I am adding 2 CUIButtons to a CuiElementContainer, but when I click on them, they a) seem to be merged together (they both depress as being clicked) and b) they pass in the same argument to the ConsoleCommand (I've tested using SendReply).
I've been trying to get to the bottom of this for hours. Any help is appreciated.
[ConsoleCommand("tp_home")]
private void tp_home(ConsoleSystem.Arg Args)
{
BasePlayer player = BasePlayer.FindByID(System.Convert.ToUInt64(Args.Args[0]));
SendReply(player, Args.Args[1]);
} public static void CreateButton(ref CuiElementContainer container, string panel, string color, string text, int size, string aMin, string aMax, string command, TextAnchor align = TextAnchor.MiddleCenter)
{
container.Add(new CuiButton
{
Button = { Color = color, Command = command, FadeIn = 1.0f },
RectTransform = { AnchorMin = aMin, AnchorMax = aMax },
Text = { Text = text, FontSize = size, Align = align }
},
panel);
}
void getMenu(BasePlayer player) {
var elements = new CuiElementContainer();
var panel = elements.Add(new CuiPanel
{
Image = {
Color = "0.1 0.1 0.1 1"
},
RectTransform = {
AnchorMin = "0.9 0.2",
AnchorMax = "1 0.8"
},
CursorEnabled = true
}, "Hud", "menu_panel");
string userID = player.UserIDString;
HomeData homeData = playerHomes[userID];
var iCount = 2;
RinslerPM.CreateButton(ref elements, panel, "0." + (iCount * 2) + " 0." + (iCount * 2) + " 0." + (iCount * 2) + " 0.2", "Test 1.1", 12, $"0.1 0.65", "0.9 0.9", $"tp_home {player.userID.ToString()} { iCount }");
iCount += 2;
RinslerPM.CreateButton(ref elements, panel, "0." + (iCount * 2) + " 0." + (iCount * 2) + " 0." + (iCount * 2) + " 0.2", "Test 2.1", 12, $"0.1 0.55", "0.9 0.9", $"tp_home {player.userID.ToString()} { iCount }");
var close_button = elements.Add(new CuiButton
{
Button = {
Command = "menu_remove " + player.userID.ToString(),
Color = "0.8 0.8 0.8 0.2"
},
RectTransform = {
AnchorMin = "0.1 0.8",
AnchorMax = "0.9 0.9"
},
Text = {
Text = "Close",
FontSize = 12,
Align = TextAnchor.MiddleCenter
}
}, panel);
CuiHelper.AddUi(player, elements);
}Merged post
Sorry @Wulf, any kind of lifeline you can throw me here? I guess having no one come back to me yet means it's not a noobish error, which is at least some comfort.