I made this code because I needed an image to display a couple seconds after an enemy spawns, but for some reason I can't make it work.
There's no error in the console, but it doesn't display the image and I don't know what to do. Here's my script (it's attached to the enemy prefab)
public class enemyAttack : MonoBehaviour {
public float time = 5f;
private IEnumerator coroutine;
public Image image;
private float t = 5f;
void Start ()
{
//image.gameObject.SetActive (false);
image.enabled = false;
coroutine = nombredeCorutina (time, image);
StartCoroutine (coroutine);
}
private IEnumerator nombredeCorutina (float t, Image im)
{
image.enabled = true;
//im.gameObject.SetActive (true);
yield return new WaitForSeconds (t);
coroutine = nombredeCorutina (time, im);
StartCoroutine (coroutine);
}
}
Invoke()
call. You really shouldn't get stuck on one method but try all methods available instead. \$\endgroup\$Canvas
object?Image
will only be rendered when nested in a Canvas. That could be your issue. \$\endgroup\$