I have this script which would make a menu appear but when i try to exit it, it doesnt respond. Like it does nothing. There is no errors at all and i cant find a answer for this. Any help?
using UnityEngine;
using UnityEngine.EventSystems;
public class ToggleGameObjectButton : MonoBehaviour
{
public GameObject objectToToggle;
public bool resetAfterClick;
void Update()
{
if (objectToToggle.activeSelf && Input.GetButtonDown(GameConstants.k_ButtonNameCancel))
{
SetGameObjectActive(false);
}
}
public void SetGameObjectActive(bool active)
{
objectToToggle.SetActive(active);
if (resetAfterClick)
EventSystem.current.SetSelectedGameObject(null);
}
}