How to know when a object is in the viewport?

I know onbecamevisible exists, but because of the way it works it’s not really correct.

Visible to the camera doesn’t mean visible to the player because it becomes visible offscreen because of shadows and whatnot.

What I need to know is when a mesh is actually in the game’s viewport.

Any ideas?

I needed the same thing to display unit UI only when the unit was visible to the camera. This is what worked for me:

bool visible = GeometryUtility.TestPlanesAABB(camera.planes, renderer.bounds);

camera is a reference to my CameraController object, in which I’ve calculated the camera’s planes using GeometryUtility.CalculateFrustumPlanes and stored them in Plane[] planes, renderer is a cached Renderer object.