Hi! I’ve been looking around to find a way to save a InputField entry (as a username) into another script, but I did not find or understand how to do it.
From now, I got 2 objects, 1 InputField and 1 EmptyObject (UI Controller).
I set up the InputField to have the Ui Controller into the On End Edit. I selected the script userNameScript, wich I have attached to my UI Controller, and finally, selected the fonction OnEntry(), wich I have written.
My OnEntry() goes like this :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class userNameScript : MonoBehaviour {
public string userName;
public GameObject inputField;
public void OnEntry()
{
inputField.GetComponent<InputField>().text = userName;
Debug.Log ("your username is " + userName);
}
}
My Debug Log returns nothing right now, as the userName is still empty and did not receives the text from the InputField.
Where did I go wrong?
Thanks a lot for you help!!