Thursday, 15 December 2016

How to make a Cheat Menu for testers

In this post I will show you how to create a simple cheat menu in your Unity game.

A simple cheat menu for Unity

What is this for?

With a cheat menu you let your testers to switch on hidden functions and let them to test the game with "unilimited lives" or "unlimited time".

How it works

An hidden menu can be obtained with a single CS script file: when the player/tester digits the "secret pass", the script will show the hidden menu. With it you can simply turn on a "trainer game", give the player infinite weapons or energy and so on...

Let's create it

  • open Unity
  • open a project (or create a new one)
  • create a new empty object in your scene
  • create a new script, let's call it "HiddenMenu.CS"
  • attach the script to your empty object

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class HiddenMenu: MonoBehaviour {

 private string[] cheatCode;
 private int index;
 private bool cheat;

 void OnGUI() {
  if (cheat) {
   // draw the hidden menu
   GUI.Box(new Rect(20, 80, 240, 240), "Cheat Menu :-) ");
   if (GUI.Button(new Rect(40, 120, 200, 20), "Reset all data")) {
    // do a total reset
   if (GUI.Button(new Rect(40, 150, 200, 20), "Reset Levels")) {
    // do a reset all levels
   if (GUI.Button(new Rect(40, 180, 200, 20), "Unlock Levels")) {
    // if you have blocked levels, here you can unlock them
    // for the testers
   if (GUI.Button(new Rect(40, 210, 200, 20), "Unlimited credits")) {
    // give unlimited CREDITS to the player
   if (GUI.Button(new Rect(40, 240, 200, 20), "Unlimited time")) {
    // give unlimited TIME to the player
   if (GUI.Button(new Rect(40, 270, 200, 20), "Close this menu")) {
    cheat = false;
    index = 0;

 void Start() {
  // The pass Code is "secret", user needs to input 
  // this word to show the hidden menu
  // You can change it whatever you want
  cheatCode = new string[] {
  index = 0;

 void Update() {
  if (Input.GetKeyDown(KeyCode.Escape)) {

  if (Input.anyKeyDown) {
   if (Input.GetKeyDown(cheatCode[index])) {
    // right input, check next digit
   } else {
    // wrong input, restart from index 0
    index = 0;

  if (index == cheatCode.Length) {
   // cheat is ok, the hidden menu is now visible :-)
   cheat = true;
   index = 0;

Let's try it !

Run your Unity game and digit your pass-code (in this example the pass-code is "secret"). You now should see the hidden menu.

Create a simple new empty object in your scene

Your cute hidden menu in Unity

Configure your preferred pass-code and create your custom methods.

And enjoy!



Post a Comment