1

嗨,我正在尝试制作一些弹出指令,我想在该人按键时禁用文本,我该怎么做?

4

2 回答 2

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
        }
    }

}
于 2020-08-09T00:46:18.427 回答
1

也许text.SetActive(false);可以工作?还是Destroy(text);

我看到这个问题已经 3 个月大了,但我希望这仍然有帮助;

于 2020-11-08T10:41:43.663 回答