UnrealScript Game Programming Cookbook

(Chris Devlin) #1
Chapter 8

233

How to do it...



  1. Start by creating a new class which will be our actual debug menu. Have
    it extend from CheatManager. You'll notice that we have this class within
    PlayerController. This allows our cheat manager (really, our debug menu)
    to capture all of our input commands. It is also a collection of executable functions
    capable of performing numerous commands.
    class DebugMenu extends CheatManager within
    PlayerController;

  2. We also want to keep these organized, so we'll use a struct record type to
    do just that.
    struct DebugCommand
    {
    var string CommandName;
    var string Command;
    };


struct SDebugCommandPage
{
var string PageName;
var array<DebugCommand> PageCommands;
};


  1. We're going to create a number of commands, so let's add the variables for
    them as shown in the following code snippet:
    var array CommandDebugPages;
    var int CurrentPage;
    var int CurrentIndex;
    var bool bShowDebugMenu;


Be sure to add the structs above your variables! Otherwise, the compiler
won't recognize the variables inside as they haven't been created yet.


  1. We need a way to turn our debug menu on and off now, so let's add the following
    code snippet:
    /*****

    • Toggles Debug Menu on and off
      *****/
      exec function ToggleDebug()



Free download pdf