So I just began coding in Unity, and I would like to activate indefinitely a GameObject, reffered below as “menuGroup”, when any key is pressed. The problem is that the object is only showing up when I press any key, it’s not staying as I want it to be. I tried anyKeyDown, but it’s only activating the GameObject for a single frame. Any suggestions?
Here is my code:
using UnityEngine;
using System.Collections;
public class MainMenuStart : MonoBehaviour {
public GameObject startText;
public GameObject startGroup;
public GameObject menuGroup;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Time.time < 2)
{
startText.SetActive(false);
menuGroup.SetActive(false);
}
else
{
startText.SetActive(true);
menuGroup.SetActive(false);
if (Input.anyKey)
{
startGroup.SetActive (false);
menuGroup.SetActive (true);
}
}
}
}
I’m sure that question sounds pretty newb-ish, but thank you in advance for your response.