Skip to content

Instantly share code, notes, and snippets.

@arxae
Created October 24, 2013 14:48
Show Gist options
  • Save arxae/7138615 to your computer and use it in GitHub Desktop.
Save arxae/7138615 to your computer and use it in GitHub Desktop.
Checks if an object is in view of a camera (Unity)
using UnityEngine;
public static class RendererExtensions
{
public static bool IsVisibleFrom( this Renderer renderer, Camera camera )
{
Plane[] planes = GeometryUtility.CalculateFrustumPlanes( camera );
return GeometryUtility.TestPlanesAABB( planes, renderer.bounds );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment