how to check GUI.TextField Entry

Right, basic question. Don’t normally ask questions like this but don’t know where to start.

So i know how to make a text field that can be filled in. Simple stuff.

I am making a code entry. So someone finds a code in the level and has to input it in order to proceed.

What do i need to look into in order to check if what has been entered into the text field is correct.

Not asking anyone to do it for me, just want to know what i have to look at in the script reference. But any code to get me kicked off would be appriciated

Here is the docs for TextField:

There’s an example that shows you how to use it. Basically, all of the Unity GUI’s operate in an ‘immediate mode’ - you call the controls as a static function and immediately receive whatever input they’ve received as a return value. You should put them all in your OnGUI() function (or functions called from it). Note: OnGUI() is called more than once every frame.

Good luck!

I figured this out. My problem was that you need to check if stringToEding is the value inside the update not the function itself. Was me being stupid. So it would work as follows:

private var stringToEdit : String = "Enter Code";

function OnGUI () {
	if(enableGUI == true) {
    	stringToEdit = GUI.TextField (Rect (10, 10, 200, 20), stringToEdit, 25);


function Update () {
	if(stringToEdit == "1234") { 
	Debug.Log("code correct");