Hey, so I've been trying to get a ui working for my plugin, but I can wrap my head around how the system works. This is what I've been able to piece together from what I've figured out in RustCui.cs and looking through the forums.
The button is created and shown on the players screen when you do /guion, but when you use guioff nothing seems to happen.Code:CuiElementContainer mainUi = new CuiElementContainer(); [ChatCommand("guion")] private void GuiOnCommand(BasePlayer player, string command, string[] args) { CuiHelper.AddUi (player, mainUi); } [ChatCommand("guioff")] private void GuiOffCommand(BasePlayer player, string command, string[] args) { CuiHelper.DestroyUi (player, mainUi.ToString()); } void OnServerInitialized () { CuiButton button = new CuiButton (); button.RectTransform.AnchorMin = "0.5 0.5"; button.RectTransform.AnchorMax = "1.0 1.0"; button.Button.Command = "kill"; mainUi.Add (button, "HUD/Overlay"); }
Also, reading through the forums I heard talk about a bug involving the names of elements, is that still out there? If so could someone explain it and let me know of any workarounds?
Thanks!
Solved Needing some help with CuiHelper
Discussion in 'Rust Development' started by Zoomafou, Oct 28, 2015.
-
Add UI panel, attach button to panel and try
// remove ToString() methodLast edited by a moderator: Oct 28, 2015 -
I switched the button to a panel but it still does the same thing
-
You don't have the correct args to the DestroyUi function.
CuiHelper.DestroyUi (player, panelName); -