I want to get all the game objects that are visible inside of a particular camera frustum. The game scene can be seen in the following image.
The scene contains various game objects such as trees, buildings, cars and pedestrian. I want to access those game objects. How can approach? Which Unity method I can use? Please help.
using UnityEngine;
public static class RendererExtensions
{
public static bool IsVisibleFrom(Renderer renderer, Camera camera)
{
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);
return GeometryUtility.TestPlanesAABB(planes, renderer.bounds);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.