How Unity works with out of camera objects?

Objects out of camera frustum still are alive consuming CPU cycles? So, it’s a good practice to take an inventory of all item and stop animation, stop calculations, etc?

Any way to stop all objects out of camera culling? (any knowed asset?)

Use OnBecameInvisible/OnBecameVisible.

–Eric

wow. thanks!

void Start() {}
void OnBecameVisible() { enabled = true; Debug.Log(“Visible”); }
void OnBecameInvisible() { enabled = false; Debug.Log(“Invisible”); }

void Update () { Debug.Log(“Update”); }

When became invisible enabled is set to false, and debbuger is stopped in “Debug.Log(“Invisible”)” (where is my breakpoint)

But when i continue, code stop in next breakpoint in ( update function), lookinh enable value is set to " true " ?? Why if after continue enable was false?

So, what’s wrong?

script are attached to a gameobject, gameobject have a render & a particle system

Anyway, I should to stop the gameobject? or the script?

What’s wrong with this code? Why Update is processed?
void OnBecameVisible() {
enabled = true;
test=true;
Debug.Log(“Visible”);
}

void OnBecameInvisible() {
enabled = false;
test=false;
Debug.Log(“Invisible”);
}

// Update is called once per frame
void Update () {
if (!test)
Debug.Log (“Why access to update if is invisible?”);
}