Skip to content
RustPluginGenerator
CS1729Oxide + Carbon

Fix CS1729: 'CuiPanel' does not contain a constructor that takes 1 arguments (Oxide)

CS1729 means you tried to build an Oxide CUI element with constructor arguments. The CUI element classes (CuiPanel, CuiLabel, CuiButton, and the rest) have no such constructors; you create them with object initializers and set their properties instead.

Server console
Error while compiling InfoPanel:
[1] 'CuiPanel' does not contain a constructor that takes 1 arguments at 26:29

Why it happens

Oxide's CUI types in Oxide.Game.Rust.Cui are plain data holders. Their fields are nested objects — Image, RectTransform, Text, Button — and those are populated through object initializer syntax, not through constructor parameters. Writing new CuiPanel("0.1 0.1 0.1 0.9") or new CuiLabel("text", 16) is a habit carried over from APIs that take a color, rect or text in the constructor, but Roslyn finds no matching constructor and reports CS1729 at the position of the (. Any count of arguments triggers it; the message just names how many you passed. The same error appears with new CuiButton(...), new CuiImageComponent(...), new CuiRectTransformComponent(...) and other CUI types, and also on ordinary classes when a plugin author assumes a constructor parameter that was never written.

How to fix it

  1. Read the line and column from the compile message (at 27:29 in the example) and open oxide/plugins/InfoPanel.cs there.
  2. Replace the constructor call with new CuiXxx { ... } and move every value you wanted to pass into the matching property.
  3. For a panel set Image = { Color = "..." } and RectTransform = { AnchorMin = "...", AnchorMax = "..." }. Leave CursorEnabled = false unless the panel needs mouse input.
  4. For a label use Text = { Text = "...", FontSize = 14, Align = TextAnchor.MiddleCenter } plus a RectTransform block.
  5. For a button use Button = { Command = "...", Color = "..." }, a RectTransform, and optionally a Text block for the caption.
  6. Save the file. Oxide reloads on save and should print Loaded plugin InfoPanel v1.0.0 by RustPluginGenerator with no CS1729 line; oxide.reload InfoPanel confirms it.

Before and after

BeforeFails
using Oxide.Game.Rust.Cui;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("InfoPanel", "RustPluginGenerator", "1.0.0")]
    [Description("Shows a small welcome panel in the top left corner")]
    public class InfoPanel : RustPlugin
    {
        private const string PanelName = "InfoPanel.Main";

        [ChatCommand("info")]
        private void CmdInfo(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;
            ShowPanel(player);
        }

        private void ShowPanel(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, PanelName);

            var container = new CuiElementContainer();

            // CS1729: CUI components are filled with object initializers, not constructor arguments
            var panel = new CuiPanel("0.02 0.85 0.22 0.97");
            panel.Image.Color = "0.1 0.1 0.1 0.85";
            panel.CursorEnabled = false;
            container.Add(panel, "Overlay", PanelName);

            var label = new CuiLabel("<b>Welcome</b>\nUse /info to toggle");
            label.Text.FontSize = 12;
            label.Text.Align = TextAnchor.MiddleCenter;
            label.RectTransform.AnchorMin = "0 0";
            label.RectTransform.AnchorMax = "1 1";
            container.Add(label, PanelName);

            CuiHelper.AddUi(player, container);
        }
    }
}
AfterFixed
using Oxide.Game.Rust.Cui;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("InfoPanel", "RustPluginGenerator", "1.0.0")]
    [Description("Shows a small welcome panel in the top left corner")]
    public class InfoPanel : RustPlugin
    {
        private const string PanelName = "InfoPanel.Main";

        [ChatCommand("info")]
        private void CmdInfo(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;
            ShowPanel(player);
        }

        private void ShowPanel(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, PanelName);

            var container = new CuiElementContainer();

            // CUI components are created empty and filled with object initializers
            var panel = new CuiPanel
            {
                Image = { Color = "0.1 0.1 0.1 0.85" },
                RectTransform = { AnchorMin = "0.02 0.85", AnchorMax = "0.22 0.97" },
                CursorEnabled = false
            };
            container.Add(panel, "Overlay", PanelName);

            var label = new CuiLabel
            {
                Text = { Text = "<b>Welcome</b>\nUse /info to toggle", FontSize = 12, Align = TextAnchor.MiddleCenter },
                RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }
            };
            container.Add(label, PanelName);

            CuiHelper.AddUi(player, container);
        }
    }
}

FAQ

Why does `new CuiPanel()` with no arguments also fail?

It does not — the CUI component classes have an implicit parameterless constructor, so new CuiPanel() is valid. CS1729 only fires when you pass arguments and no constructor with that signature exists. Use new CuiPanel { ... } to set fields.

Can I write my own constructor wrapper for CUI elements?

Yes, but it must live in your plugin, not on the CUI type. A private helper that builds and returns a CuiPanel with the fields already set is fine. You cannot add constructors to CuiPanel because it belongs to Oxide's assembly.

The error points at a class I wrote, not a CUI type. What then?

CS1729 is the same rule: you called new MyClass(arg) but MyClass only has a parameterless constructor. Add the constructor you expect, or switch to an object initializer and public fields or properties.

Different error?

Paste the full console output and get the cause and a fix in plain English.

Open the error explainer

Skip the debugging

Generated plugins are compiled before you get them, and compiler errors are fixed automatically.

Generate a plugin

2 free plugins a month, no card.

Last updated Oct 26, 2026.

Get plugins that compile first time

Generate