container.Add(new CuiElement
{
Parent = tpt,
Components =
{
new CuiInputFieldComponent
{
Align = TextAnchor.MiddleCenter,
Color = "0.5 0.5 0.5 0.5",
CharsLimit = 8,
Text = FExampleInputText.ContainsKey(player.UserIDString) ? FExampleInputText[player.UserIDString] : string.Empty,
FontSize = 12,
IsPassword = false,
Command = "sr.data",
NeedsKeyboard = true
},
new CuiRectTransformComponent {AnchorMin = "0.01 0.02", AnchorMax = "0.75 0.13" }
}
});
container.Add(new CuiButton
{
Button = { Color = "0.5 0.5 0.5 0.5", Command = $"chat.say \"/sethome {FExampleInputText[player.UserIDString]}\"" },
RectTransform = { AnchorMin = $"0.8 0.02", AnchorMax = $"0.89 0.13" },
Text = { Text = $"add", Align = TextAnchor.MiddleCenter, FontSize = 12 },
}, tpt);When the player inputs, I have already saved an sr.data and can print it. The problem is that when I do not input, a null error message will appear
I tried adding string text=FExampleInputText. Add (player. UserIDString, "") first;
But the button cannot obtain text, which makes me very puzzled