Hi all,
Unity's optimization page suggests using the OnBecameVisible/OnBecameInvisible functions.
I have a cube that is outside the camera's view frustum (its about 30 meters behind the player) and I have a script attached to the cube with the following code:
function OnBecameVisible () {
print("VISIBLE");
}
function OnBecameInvisible () {
print("INVISIBLE!");
}
I'd like to have it print a message when the cube is in the camera's frustum and when it leaves the camera's frustum. Unity's documentation reads, "This message is sent to all scripts attached to the renderer." The cube does have a mesh renderer and when the scene starts I receive a "VISIBLE" (even though I start not facing the cube) and then when I face the cube and turn away (180' or an about face) it doesn't give me the "INVISIBLE" message. As I said I'm ~30 meters away so I'm confused why this is happening. Also it will only give me a "VISIBLE" message on start up. Looking away and back at the cube produces no more messages. Any suggestions? Thanks!