Hello I'm looking for a plain UI example, so I can get the grips on how UI works in plugins, so if any one can make a plugin or know a plugin with plain UI that would be great (C#)
Plain UI example?
Discussion in 'Rust Development' started by MisterPixie, Apr 2, 2016.
-
take a look at the helper classes here:
Oxide/RustCui.cs at master · OxideMod/Oxide · GitHub
you can use the CuiElementContainer and add CuiPanel, CuiLabel, CuiButton to it or create your own CuiElement with its components (CuiTextComponent, CuiImageComponent, CuiRawImageComponent, CuiButtonComponent, CuiOutlineComponent, CuiNeedsCursorComponent, CuiRectTransformComponent)
i've a simple test plugin here:
Code:using Oxide.Game.Rust.Cui; using Oxide.Ext.Example;using UnityEngine;namespace Oxide.Plugins { [Info("CuiExample", "Nogrod", "0.0.1")] internal class CuiExample : RustPlugin { private void Init() { Puts(Test.GetValue()); } [ChatCommand("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 = "hallooo" + i, FontSize = 18, Align = TextAnchor.MiddleCenter }, RectTransform = { AnchorMin = $"0.06 {1 - 0.07*i + 0.006}", AnchorMax = $"0.85 {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.86 {1 - 0.07*i + 0.006}", AnchorMax = $"0.97 {1 - 0.07*(i - 1)}" }, Text = { Text = "+", FontSize = 22, Align = TextAnchor.MiddleCenter } }, mainName); } CuiHelper.AddUi(player, elements); } } }
-