inactive after active with press key unity code example
Example 1: inactive after active with press key unity
if (Input.GetKeyDown(KeyCode.Escape))
{
yourObject.SetActive(!yourObject.activeSelf);
}
Example 2: inactive after active with press key unity
public GameObject shieldObject;
if (Input.GetKeyDown(KeyCode.LeftShift))
{
shieldObject.SetActive(true);
}
else if (Input.GetKeyUp(KeyCode.LeftShift))
{
shieldObject.SetActive(false);
}