Quantcast
Channel: Questions in topic: "renderer.enabled"
Viewing all articles
Browse latest Browse all 99

Simple coroutine doesn't resume after setting renderer.enabled to false

$
0
0
Hello everyone, I'm trying to make a bonus that starts with a trigger and last for one second. I've made a coroutine for that. here's my simplified code. Here's what I get in the console : About to StartCoroutine disable about to yield return WaitForSeconds(1) back from StartCoroutine And never get the "Just waited 1 second" log, as long as I have the ligne renderer.enabled = false or gameObject.SetActive(false). When I remove that line everyhting works perfectly... But I still need to hide the gameObjectand disable it's collider. void OnTriggerEnter2D () { activated = true; Debug.Log ("About to StartCoroutine"); StartCoroutine (MyCoroutine ()); Debug.Log ("Back from StartCoroutine"); } IEnumerator MyCoroutine () { this.Disable (); Debug.Log ("about to yield return WaitForSeconds(1)"); yield return new WaitForSeconds (1); Debug.Log ("Just waited 1 second"); } void Disable () { Debug.Log ("disable"); this.collider2D.enabled = false; this.renderer.enabled = false; //gameObject.SetActive (false); } Do you have any idea ?

Viewing all articles
Browse latest Browse all 99

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>