Input.GetKeyDown(KeyCode.F1) not working

Greetings,

I’ve added a help screen to my game to display control mappings. I am able to display the screen with a button that I added:
6131894--668660--upload_2020-7-25_18-9-52.png


However, I would also like to display the screen if the user presses F1.

I’ve added the following script to my HelpScreen GameObject:

using UnityEngine;

public class HelpScreen : MonoBehaviour
{
    [SerializeField]
    PauseManager pauseManager = null;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F1))
        {
            Debug.Log("F1 pressed.");
            if (pauseManager != null)
            {
                pauseManager.PauseGame(false);
                gameObject.SetActive(true);
            }
            else
            {
                Debug.Log("pauseManager unassigned.");
            }
        }
    }
}

It appears that the F1 keypress is never registering. I never get the log message I’m emitting for it and the help screen doesn’t display.

Any ideas why that would be?

And while I’ve got your attention, does anybody know of any attractive keyboard & mouse icons/sprites I would put on the help screen instead of plain text?

Thanks.

This line of code seems really fishy to me^^^

If the GameObject is not active, Update will not run at all. That means this code will never run in the first place. Did you disable the GameObject that this script is attached to?

1 Like

Duh! Rookie mistake.