Serial codes to unlock levels

Hi!

I am making a game and I want to test something I never have done before. Serial codes to unlock levels. Like you can have a level or multiple levels who needs a code to get activated. So what I need is a GUI box where you can write a code and if the code is right, it will do stuff, but if it wrong, nothing. You can also set what codes it can confirm. So in the inspector you can set like 1234, 17921 and 18391 and it would accept it if one of these if put in. But my problem is, I don’t know how to code this. So if anyone could help me, please help me. Also, please post it in JavaScript.

Thanks

Also, I did some code with a text field and now I only need to know how I can detect it.

var stringToEdit : String = "";

var serialKeys : String[];

function OnGUI () {
	
	GUI.Box(Rect(Screen.width /2 - 100,Screen.height /2 - 25,250,25),"Insert Serial Number");
	
	// Make a text field that modifies stringToEdit.
	stringToEdit = GUI.TextField (Rect(Screen.width /2 - 100,Screen.height /2 ,250,25), stringToEdit, 20);
}

Hi! i made this simple cheat code , as simple as possible: i hope it helps.

just add to the main camera to test it. The currect code is “12345”.
And is good to unlock : safes, doors panels code etc…
Enjoy! happy new year.

#pragma strict

var passwordToEdit : String = ""; // type you password
var curPassword : String = "12345"; // The currect password needed to unlock staff
private var showlavel : boolean = false;


function OnGUI () {


    passwordToEdit = GUI.PasswordField (Rect (10, 10, 200, 20), passwordToEdit, "*"[0], 25);
    
    //Check if the password is Good or Bad password
    if (passwordToEdit == curPassword)
    {
        GUI.Label(Rect(10,100,100,50), "Cheat code Found! Press ok to check!");        
    }
    else
    {
        //Show Bad password.
        GUI.Label(Rect(10,100,100,50), "No cheat found");
        showlavel = false;        
    }    
    
    // if The password is Good show the check Button.
    if (curPassword == passwordToEdit)
    {
        if (GUI.Button(Rect(10,150,150,50), "check?"))
        {
            showlavel = true;
            //Do some magic code...
            print("Good password");
        }        
    }
    
    // Show Information of the cheat.
    if (showlavel==true)
    {
        GUI.Label(Rect(190,150,150,50), "Good password! You unlock infinite health");
    }
}