I am trying to code a game in C# where if you collect something, text will show for 10 seconds and then disappear. I am trying to use WaitForSeconds, but when i collect the object, the text just stays on the screen. Here is my code.`using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class CoordinatingConjunctionText : MonoBehaviour {
public Text CcText;
// Use this for initialization
void Start () {
CcText.text = "";
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter (Collider other)
{
if (other.gameObject.CompareTag ("Player"))
{
CcText.text = "COORDINTATING CONJUNCTION" +
"
-Most common of 3 types" +
"
-Joins words, phrases, and clauses together" +
"
-Goes between the words that are being linked" +
"
Ex. Apples AND Cheez-Its are my favorite snacks." +
"
Ex. I had to climb the mountain, explore the cave, OR scuba dive." +
"
Ex. How he sings AND how he talks are very different.";
WaitAndCloseText ();
}
}
IEnumerator WaitAndCloseText ()
{
yield return new WaitForSeconds(10);
%|-436420141_29|%
}
}
`
I’m sorry that not all the code is there, the system did something funny. Here is a picture of all of it.