hello, i'm trying to build a simple UI script where when the player presses E the dialogue menu comes up and when he presses esc the dialogue menu disappears. im trying to do so by using SetActive. pressing e sets it as active (true) while escape does nothing, and the canvas remains on the screen. any help?
i dno't have any other script that references this game object at all, so i don't understand what's wrong
public class WomanNPC : MonoBehaviour
{
private GameObject triggeringPlayer;
private bool triggering = false;
public GameObject dialogueBox;
//public string name = womanNPC;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (triggering)
{
if (Input.GetKey("e"))
{
//this works
dialogueBox.SetActive(true);
if (Input.GetKey(KeyCode.Escape))
{
//this does not
dialogueBox.SetActive(false);
}
}
}
}