Check if object is being rendered

Is there a way to check if a object is within any cameras render area?

renderer.isVisible

Yes! I don't know how often you'd want to check it, but if you want it per frame..

var objectToStalk : GameObject;
private var objectToStalkRenderer : Renderer; // Cache this so its faster

function Start()
{
 objectToStalkRenderer = objectToStalk.renderer; // This reduces a get_component call in the update loop
}

function Update()
{
  if (objectToStalkRenderer.isVisible) print ("Jessica Alba is hot.");
}

Note that the object is considered visible when it needs to be rendered in the scene. For example, it might not actually be visible by any camera but still need to be rendered for shadows. When running in the editor, the scene view cameras will also cause this value to be true.

from → Unity - Scripting API: Renderer.isVisible

(Just in case anyone’s still looking for this solution)

sorry for wakening an old thread, but in case a newbie stumbles upon this:

Nowadays it should be called gameObject.GetComponent<Renderer>.isVisible .

If you are using a Screen Space Canvas, you can check with this script:

using UnityEngine;

public class VisibleTest : MonoBehaviour
{
    RectTransform rect;
    Rect screenBounds = new Rect(0f, 0f, Screen.width, Screen.height);

    void Start()
    {
        rect = GetComponent<RectTransform>();
    }

    void Update()
    {
        Debug.Log(IsVisible());
    }

    public bool IsVisible()
    {
        Vector3[] corners = new Vector3[4];
        rect.GetWorldCorners(corners);

        for (var i = 0; i < corners.Length; i++)
        {
            if (screenBounds.Contains(corners*))*

{
return true;
}
}

return false;
}
}