Search Unity

Creating Debug Menus using keyboard input

Discussion in 'Editor & General Support' started by SimonMK7, Oct 23, 2020.

  1. SimonMK7

    SimonMK7

    Joined:
    Sep 13, 2018
    Posts:
    4
    Does anyone know where i could find more information on how to create these kinds of menus? I want to start debugging my project but wanted to add a debug menu in order to be able to test different parts of my game. however, every tutorial I find on youtube is about how to create the main menu using the unity event system or some other variation. I specifically want to create one where the player would use the keyboard inputs in order to scroll through various options. while simple, I've yet to find one. does anyone have any suggestions?
     

    Attached Files:

  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Unity doesn't have a built in system for old school style text menus with a cursor that moves up and down the screen. My guess is that would be fairly complex to write in Unity from scratch, but debug menus usually look pretty plain because they are thrown together quick and dirty.

    It is possible you could find an asset on the Asset Store which implements this kind of menu, but I'd be surprised since it doesn't seem like something that would have a whole lot of demand.

    Usually debug menus in Unity are done via IMGUI
    https://docs.unity3d.com/Manual/GUIScriptingGuide.html

    If I were to create a debug menu somewhat like you want, I'd probably just use the regular UI, put a large UI.Text filling most of the window, and an InputField at the bottom. Then you can fill the UI.Text with whatever text you want, and on each line put a number. The user then writes the number in the InputField. Watch the InputField for the enter key to use as submit, or add a separate submit button. Then just parse the input for an integer to determine the user's selection.
     
    Last edited: Oct 23, 2020
  3. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    What specific part are you having trouble with? Displaying the menu, getting keyboard input, or something else?

    For what it's worth, this isn't a "game design" question. You're likely to get a better response in the scripting or UI areas.