Game doesn't seem to register space key press

I have got to the point where I am trying to change the text.text from “Hello World” to “Space key pressed”

However, after starting the game, it doesn’t progress from the “Hello world” screen after pressing space.
I tried testing with different keys and keycodes and nothing worked.

Here is my code:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class TextController : MonoBehaviour {

public Text text;

// Use this for initialization
void Start () {
	text.text = "Hello World";
}

// Update is called once per frame
void Update () {
	if (Input.GetKeyDown(KeyCode.Space)){
		text.text = "Space key pressed";
	}
}
}

The screen stays like this even after multiple presses of the space key.

1 Like

So I left it over night, and came back to it today, and it seemed to work first time… I guess that proves that sometimes the best thing to is sleep on it and try again tomorrow!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms