Hi,
Found an excellent post about checking “Is target in view frustrum”. If i understand it correctly, we would stop rendering of an object by disabling its Renderer when off screen. But as soon as i do this …
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void OnBecameInvisible() {
GetComponent<MeshRenderer>().enabled = false;
}
void OnBecameVisible() {
GetComponent<MeshRenderer>().enabled = true;
}
}
… and the object leaves camera frustrum, Its Renderer does not dispatch OnBecameVisible again, once it later again enters the camera frustrum - well, thats obvious, since we disabled it in the first place - so a disabled Renderer would not fire OnBecameVisible.
What gives? Using this culling technique i cant do the culling.
Further more i wanted to actually disable the whole GameObject (not only its Renderer) when it leaves frustrum. Any thoughts on the best-practise implementation-vise here? I guess you cant use Renderer’s isVisible/OnBecameVisible/OnBecameInvisible? Is using WorldToScreenPoint favored approach in this case? Is there better approach than disabling whole GameObject performance-vise?
Brainstorm please, tested methods preferred!