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

OnBecameVisible does not work

$
0
0
I am trying to optimize CPU usage for the game so I stop rendering when the object is out and render it again when it come back to screen. But the second part I can't get it to work. The Cat disappeared but never appeared again even I could see it in the Hierachy in editor. The code is followed: using UnityEngine; public class CatUpdater : MonoBehaviour { private CatController catController; void Start () { catController = transform.parent.GetComponent(); } void UpdateTargetPosition() { catController.UpdateTargetPosition(); } void GrantCatTheSweetReleaseOfDeath() { Destroy( transform.parent.gameObject ); } void OnBecameInvisible() { renderer.enabled = false; catController.OnBecameInvisible(); } void OnBecameVisible() { if (!renderer.enabled) { Debug.Log("Cat is visible " +gameObject.name); renderer.enabled = true; } } }

Viewing all articles
Browse latest Browse all 99

Trending Articles



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