#you can change GameObject to
1 messages · Page 1 of 1 (latest)
The GameObject is Input Field/Text Area/Text, and the component is Text's own TextMeshProUGUI. Text Area also contains another child, Placeholder. That's literally the construction created by Unity when creating a Text Input Field object
how do i drag a component from one object into a script attached to another?
yes but the root gameobject contains a InputField script
and everything you need can be find in that script
drag the whole gameobject that contains the component, it will automatically detect the correct component
or you can just drag & drop the component directly
oh?
how do i do the latter? it would require the Inspector to switch from the component's owner object to the script's owner object while i drag
Yea you can't do that everytime so just use the first solution
I just tried it. It keeps working the way it did before. So, it doesn't trigger the Interactable of the button
what's worse, even when set to non-interactable by force, it re-enables itself immediately
yes meaning that the text is always greater than 1
so your code works, but the way you're getting the text doesn't
i have the string serialized, so i can see it in the inspector while testing
it starts empty
do you have messages in the console by any chance?
I tried printing the name to the console with ```cs
Debug.Log("The player's name is '" + playerName + "'.")
and with an empty input field the resulting message is
The player's name is ''.
so the string length is literally 0
thats weird
try using string.isNullOrEmpty(playerName);
this is the recommended way to check if a text is empty (or null)
and my condition for the flag is
if (playerName.Length < 1)
{}
else
{}
i tried string.IsNullOrEmpty
still doesn't work
whats your code to get the text this time?
still the same
playerName = nameInputTextField.text;
i also tried IsNullOrWhiteSpace, same result
well i don't know what to tell you, its supposed to work, there is something else that you did that makes the thing not working
i googled and it looks like i'm not the only one with the problem
can you show me an example?