Implement cheat codes

The central mechanic of my game is to use cheat codes to win. I need an elegant solution that is easy to manage, even if there are lots of cheats. I don’t need to know the code yet, just the the technique, as figuring out the code isn’t a problem for me.

My guess is that i could make a cheatCode class (wich stores the right string of commands) and a script that checks the last inputs against all the instances of the cheatCode class. So when the right cheat is found, it triggeres a unique script (contained in each cheatCode class).
But is there a better way of doing things?

@unity_K6RcJy9pYhlbug

From what you said, Im assuming that you are going to compare a list of strings(the cheat codes) with the input string(the cheat code the user input) when the player hits the enter button. I suggest having an array of all possible cheat codes together with what script they will activate. the array will be from a class with all necessary data of cheat codes.

something like this:

 class nameOfYourScript : MonoBehaviour
    {
    [system.serializable]
    public class cheatData {
        //self explanatory
        public string nameOfCheat;
        // when the system found the cheat, which object in the scene where unity get the script
        public gameObject objectToCallScriptFrom;
        // name of function in script
        public string functionWhereYouCallScript;
    }
    public cheatData[] cheatCodes;
    // compare the strings...
    //....
    //compare the strings...
    // action where system find a cheat code
    void OnCheatEnter(GameObject obj, string function)
    {
        // Invokes the function
        obj.Invoke(function, 0f);
    }
    
    }

This is how I will do it. This code above is just a guide and may have errors, did not check i myself. However i hope it can help :). Good luck with your game development!

Cheers,
phletic