Is there a tutorial for Unity 4.6 that shows how to print data from a text field when a button is clicked.

I’m working on an educational application that requires a word and definition be saved to a database, but I can’t get past the part where I save the word and definition data entry when a button is pressed. I’m using Unity 4.6 and C#. Any advice is appreciated. I can’t find a coherent tutorial on this anywhere.

This is the script:

using UnityEngine;
using UnityEngine.UI; // Import the UI System
using System.Collections;

public class Test : MonoBehaviour {
	public InputField myInputField; // Attach in inspector
	public ArrayList myDataBase = new ArrayList();


	// The Function what you call from click (MUST BE PUBLIC)
	public void PressButton () {
		if (myInputField.text.Length > 0) {
			myDataBase.Add(myInputField.text);
			Debug.Log(myInputField.text);
		}else {
			Debug.Log("NoText");
		}
	}

}

Attach this script to Canvas or other gameObject, and assign the myInputField variable in the inspector.


Select your button and assing this gameObject To OnClick() Event: