is called after culling has determined that the object will be rendered, but before the object is rendered by each camera. It's called once per camera that will render the object, for every visible, non-UI object with this MonoBehaviour.
OnWillRenderObject
is called multiple times per frame. It's not called on disabled MonoBehaviours.
OnWillRenderObject
is appropriate for: - Per-camera material or shader adjustments, for example setting shader keywords or per-camera uniforms. - Per-camera logic that doesn't affect the object's transform or visibility. - Custom rendering logic, like setting up camera-dependent effects.
OnWillRenderObject
is not appropriate for: - Modifying the object's position or transform. This is because the culling process (which decides if an object is visible) has already occurred. If you move the object here, it may already be included in the render list for this frame, and the scene may not update as expected. You could see visual artifacts, popping, or inconsistent rendering results. - Changing the camera. You can read from Camera.current, but changing camera settings here is generally not recommended. If you need to change camera settings before culling, use MonoBehaviour.OnPreCull() or MonoBehaviour.OnPreRender() instead. Camera.current will be set to the camera that will render the object. Note: