Created
October 24, 2013 14:48
-
-
Save arxae/7138615 to your computer and use it in GitHub Desktop.
Checks if an object is in view of a camera (Unity)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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