查看物体A是否被相机B渲染

时间:2014-05-05 22:00:12   收藏:0   阅读:357
bubuko.com,布布扣
using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour {

    public GameObject anObject ;
    private Camera cam ;
    private Plane[] planes ;
    
    void Start() {
        cam = Camera.main;
        planes = GeometryUtility.CalculateFrustumPlanes(cam);
    }
    
    void Update() {
        if(GeometryUtility.TestPlanesAABB(planes,anObject.collider.bounds))
            Debug.Log(anObject.name + " has been detected!");
        else
            Debug.Log("Nothing has been detected");
    }
}
bubuko.com,布布扣

 官网地址:http://docs.unity3d.com/Documentation/ScriptReference/GeometryUtility.TestPlanesAABB.html

查看物体A是否被相机B渲染,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!