#you can change GameObject to

1 messages · Page 1 of 1 (latest)

rich cradle
#

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?

tame widget
#

yes but the root gameobject contains a InputField script

#

and everything you need can be find in that script

tame widget
#

or you can just drag & drop the component directly

rich cradle
#

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

tame widget
#

Yea you can't do that everytime so just use the first solution

rich cradle
#

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

tame widget
#

yes meaning that the text is always greater than 1

#

so your code works, but the way you're getting the text doesn't

rich cradle
#

i have the string serialized, so i can see it in the inspector while testing

#

it starts empty

tame widget
#

do you have messages in the console by any chance?

rich cradle
#

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

tame widget
#

thats weird

#

try using string.isNullOrEmpty(playerName);
this is the recommended way to check if a text is empty (or null)

rich cradle
#

and my condition for the flag is

if (playerName.Length < 1)
{}
else
{}
#

i tried string.IsNullOrEmpty

#

still doesn't work

tame widget
#

whats your code to get the text this time?

rich cradle
#

still the same
playerName = nameInputTextField.text;

#

i also tried IsNullOrWhiteSpace, same result

tame widget
#

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

rich cradle
#

i googled and it looks like i'm not the only one with the problem

tame widget
#

can you show me an example?