Question by
Glubs · Sep 07, 2016 at 10:21 AM ·
programmingissue
unity doesn't sense more than one key press C#
when i open my project i can only see 1 letter in the debug log it also doesn't show the sprite after i press x than c.
here is my code using UnityEngine; using System.Collections;
public class hide_show : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown("z"))
{
gameObject.SetActive(false);
Debug.Log("z");
}
if (Input.GetKeyDown("x"))
{
gameObject.SetActive(false);
Debug.Log("x");
}
if (Input.GetKeyDown("c"))
{
gameObject.SetActive(true);
Debug.Log("c");
}
}
}
Comment
Answer by doublemax · Sep 07, 2016 at 10:41 AM
Once you set the GameObject to inactive with gameObject.SetActive(false) the Update() method won't get called any more.
I would attach the script to a different object (one that never gets de-activated) and add a public variable for the GameObject you want to hide/show.