Question by
sqbernardo · Feb 03, 2019 at 01:33 PM ·
textimage
How to make a text and image appear for few seconds if you pick up a gameobject?
I'm begginer and I'm trying to make a text and image appear for a few seconds when the FPS Player picks up a key card, but it does not appear, and if I switch to ! = Null the system does not stop reading. Could you help me, please?
public class CardMessage : MonoBehaviour
{
public GameObject keycard;
[SerializeField] private RawImage Painelcartao;
[SerializeField] private Text coletaCartao;
private void Start()
{
Painelcartao.enabled = false;
coletaCartao.enabled = false;
}
void Update()
{
if (GameObject.Find("keycard") == null)
{
Painelcartao.enabled = true;
coletaCartao.enabled = true;
StartCoroutine("Wait", 3f);
}
}
IEnumerator Wait(float time)
{
Debug.Log("ENTER IN ENUMERATOR.");
yield return new WaitForSeconds(3f);
Destroy(GetComponent<RawImage>());
Destroy(GetComponent<Text>());
}
}
Comment
Your answer
Follow this Question
Related Questions
How do I make both an Image and Text appear when a button is clicked? 0 Answers
Text and Image fill lerp issues - Android 0 Answers
How to display UI elements at all? 0 Answers
Input field to image 0 Answers