Tarek Auf der Strasse
Tarek Auf der Strasse

Reputation: 35

Unity Input field not setting value on change

I simply want to set a room name using input fields and the fact that it can pass the input through as an argument, but this does not seem to work for some reason.
here is the function that is called
Codeenter image description here

here is the output in the console when typing in the field
enter image description hereenter image description here

why does it send in a blank string?
I followed this tutorial: Youtube

Upvotes: 2

Views: 2221

Answers (3)

Display name
Display name

Reputation: 467

It hasn't been explained well but you want to select the top method under dynamic value. If you look at this image, you will see two methods, selecting the bottom (static) one will show the input field as you see but the top (dynamic) one (which is what you want) will show no input field. An example of what to do

Upvotes: 0

Tarek Auf der Strasse
Tarek Auf der Strasse

Reputation: 35

I worked around this by creating a reference to the text in "SetRoomName" it's not ideal but works

Upvotes: 0

Pluto
Pluto

Reputation: 4061

When you add a listener (HostGame.SetRoomName) you have two sections from which you can choose your functions: Dynamic string and Static Parameters. Your function should be in both sections:

  • Dynaic string - SetRoomName
  • Static Parameters - SetRoomName(string)

You have to choose the first one if you want to receive as parameter the input field text. The parameter in the second option is whatever you put in the field below HostGame.SetRoomName in your first image (in your case blank).

Upvotes: 2

Related Questions