public override void OnInspectorGUI()
        {
            CheatCodeSettings settings = (CheatCodeSettings)target;

            CheatCodeSettings.SetInstance(settings);
            cheatCodes = CheatCodeSettings.CheatCodes;

            EditorGUILayout.LabelField("Cheat Codes");

            EditorGUILayout.HelpBox("A list of all cheat codes", MessageType.None);

            CheatCodeSettings.CheatCodeLength = EditorGUILayout.IntField(cheatLenghtLabel, CheatCodeSettings.CheatCodeLength);

            EditorGUILayout.Space();

            for (int i = 0; i < cheatCodes.Count; i++)
            {
                EditorGUILayout.LabelField("Cheat Code " + (i + 1) + " - " + cheatCodes[i].name);
                cheatCodes[i].name      = EditorGUILayout.TextField(userFriendlyLabel, cheatCodes[i].name);
                cheatCodes[i].shortCode = EditorGUILayout.TextField(shortCodeLabel, cheatCodes[i].shortCode);

                EditorGUILayout.LabelField("Cheat Code Sequence");

                for (int o = 0; o < CheatCodeSettings.CheatCodeLength; o++)
                {
                    GUIContent step = new GUIContent("Step " + (o + 1));
                    cheatCodes[i].cheatCodeSequence[o] = (KeyCode)EditorGUILayout.EnumPopup(step, cheatCodes[i].cheatCodeSequence[o]);
                }

                if (GUILayout.Button("Delete this cheat code!"))
                {
                    cheatCodes.Remove(cheatCodes[i]);
                    SaveAsset(settings);
                }

                EditorGUILayout.Space();
            }

            if (GUILayout.Button("Add New Cheat Code"))
            {
                CheatCode newCheatCode = new CheatCode();
                newCheatCode.name              = "New Cheat Code";
                newCheatCode.shortCode         = "newCheatCode";
                newCheatCode.cheatCodeSequence = new List <KeyCode>(CheatCodeSettings.CheatCodeLength);

                //prepopulate with empty strings, otherwise gives error as setting the capacity above does nothing
                for (int i = 0; i < CheatCodeSettings.CheatCodeLength; i++)
                {
                    newCheatCode.cheatCodeSequence.Add(KeyCode.A);
                }
                cheatCodes.Add(newCheatCode);

                SaveAsset(settings);
            }

            if (GUI.changed)
            {
                Debug.Log("gui changed");
                SaveAsset(settings);
            }
        }
 void OnDisable()
 {
     // make sure the runtime code will load the Asset from Resources when it next tries to access this.
     CheatCodeSettings.SetInstance(null);
 }