Hi I am trying to make some popup instructions I want to disable the text when the person presses a key how might I do that?
Asked
Active
Viewed 6,578 times
2 Answers
3
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; // Namespace for Unity's UI system
public class EnableAndDisableText : MonoBehaviour {
[SerializeField] Text text; // Text that you want to disable
private void Update() // Called every frame
{
if (Input.GetKeyDown(KeyCode.E)) // If the 'E' key is pressed,
{
text.enabled = false; // Disable text
}
}
}

Easwar Chinraj
- 436
- 1
- 4
- 10

MysticalUser
- 404
- 5
- 13
-
I got a error ```error CS0116: A namespace cannot directly contain members such as fields or methods``` – Lumic Aug 09 '20 at 04:55