You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
840 B
32 lines
840 B
9 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace UnityTest
|
||
|
{
|
||
|
public class IsRenderedByCamera : ComparerBaseGeneric<Renderer, Camera>
|
||
|
{
|
||
|
public enum CompareType
|
||
|
{
|
||
|
IsVisible,
|
||
|
IsNotVisible,
|
||
|
};
|
||
|
|
||
|
public CompareType compareType;
|
||
|
|
||
|
protected override bool Compare(Renderer renderer, Camera camera)
|
||
|
{
|
||
|
var planes = GeometryUtility.CalculateFrustumPlanes(camera);
|
||
|
var isVisible = GeometryUtility.TestPlanesAABB(planes, renderer.bounds);
|
||
|
switch (compareType)
|
||
|
{
|
||
|
case CompareType.IsVisible:
|
||
|
return isVisible;
|
||
|
case CompareType.IsNotVisible:
|
||
|
return !isVisible;
|
||
|
}
|
||
|
throw new Exception();
|
||
|
}
|
||
|
}
|
||
|
}
|