嗨,我正在尝试制作一些弹出指令,我想在用户按键时禁用文本,我该怎么做?
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
}
}
}
也许text.SetActive(false);
可以工作?还是CCD_ 2?
我知道这个问题已经3个月了,但我希望这仍然有帮助;
private void Update()
{
if (Input.GetKeyDown(KeyCode.A)) // If the 'A' key is pressed
{
text.gameObject.SetActive(false);
}
}