Object rotation when gameobject moves out of camera vision

I am having an object moving. i want to rotate my game object when it moves outside the camera view.but how do we know that the game object has moved out of camera vision.

OnBecameInvisible.

–Eric

but it still ain’t working… i used the code below

function OnBecameInvisible()
{
transform.Rotate(0,180,0);
}

The editor camera also counts…either test it as a stand-alone build, or make sure the editor camera is pointing somewhere else so it doesn’t affect things.

–Eric