How to obtain the text input by players in CuiInputFieldComponent from the CUI button?Solved
			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

Instead of typing the condition into the `text` property of the CUIInputField. Add a condition to the button.

container.Add(new CuiButton
{
	Button = { Color = "0.5 0.5 0.5 0.5", Command = $"chat.say \"/sethome {FExampleInputText.ContainsKey(player.UserIDString) ? FExampleInputText[player.UserIDString] : string.Empty}\"" },
	RectTransform = { AnchorMin = $"0.8 0.02", AnchorMax = $"0.89 0.13" },
	Text = { Text = $"add", Align = TextAnchor.MiddleCenter, FontSize = 12 },
}, tpt);
oESHrLEd4Ji1r5d.jpg ArtiIOMI

Instead of typing the condition into the `text` property of the CUIInputField. Add a condition to the button.

container.Add(new CuiButton
{
	Button = { Color = "0.5 0.5 0.5 0.5", Command = $"chat.say \"/sethome {FExampleInputText.ContainsKey(player.UserIDString) ? FExampleInputText[player.UserIDString] : string.Empty}\"" },
	RectTransform = { AnchorMin = $"0.8 0.02", AnchorMax = $"0.89 0.13" },
	Text = { Text = $"add", Align = TextAnchor.MiddleCenter, FontSize = 12 },
}, tpt);

Thank you, it's resolved

Locked automatically