Saturday 15 March 2014

c# - How to use the "On Value Change" in Unity3D Input Field UI component -


I follow a tutorial on how to work with Unity 3D and I hit a dead end is.

I believe there is a change in a new version of unity because the tutorial works well as I am doing this.

I have an input field UI component that I want to make every call to the C # function, I change it.

According to the tutorial, I need to use the "On Value Change" property of the input field (script) and ask it to call some functions which string as an argument .

  public string player name; Public Zero Setname (string name) {playerName = name; Debug. Log ("Set Player Name:" + name, gameObject); Debug. Logs ("get the player name:" + player name, game object); }  

However, this is nothing, my playerName property is always empty and I do not get anything in name .

How can I go about doing this? I have seen the answer to the establishment of a listener in the start () function, and then here we have seen using UnityEvent :

but there is another Is there any way to use Unity 3D graphical editor to do so that does not include writing this code?

Yes you can add event handlers through the inspector InputField Select the game object and in the inspector Scroll down to the InputField section. Click + to add a new event handler, then select the received game object and method you want to call.

Enter image details here


No comments:

Post a Comment