I'm following a tutorial on how to work with Unity3d and I've hit a dead end.
I believe something changed in a newer version of Unity since the tutorial seems to work nice the way I'm doing it.
I have an Input Field UI component that I want to call a C# function every time I change it.
According to the tutorial I just have to use the "On Value Change" property of the Input Field (script) and tell it to call some function that takes a string
as an argument.
public string playerName;
public void setName (string name)
{
playerName = name;
Debug.Log("Set playerName: "+name, gameObject);
Debug.Log("Get playerName: "+playerName, gameObject);
}
Yet, this does nothing, my playerName
property it's always empty and I don't receive anything in name
.
How do I go about doing this? I've seen an answer setting up a listener in the Start()
function, and then using an UnityEvent
in here: Get text from Input field
But is there another way to do this using the Unity3d graphical editor that doesn't involve writing so much code?