You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
664 B
C#
25 lines
664 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine.UI;
|
|
|
|
namespace MoreMountains.Tools
|
|
{
|
|
/// <summary>
|
|
/// Renderer extensions
|
|
/// </summary>
|
|
public static class RendererExtensions
|
|
{
|
|
/// <summary>
|
|
/// Returns true if a renderer is visible from a camera
|
|
/// </summary>
|
|
/// <param name="renderer"></param>
|
|
/// <param name="camera"></param>
|
|
/// <returns></returns>
|
|
public static bool MMIsVisibleFrom(this Renderer renderer, Camera camera)
|
|
{
|
|
Plane[] frustumPlanes = GeometryUtility.CalculateFrustumPlanes(camera);
|
|
return GeometryUtility.TestPlanesAABB(frustumPlanes, renderer.bounds);
|
|
}
|
|
}
|
|
} |