码迷,mamicode.com
首页 > 其他好文 > 详细

判断物体是否在摄像机内

时间:2014-11-11 12:34:35      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   ar   os   sp   div   on   

    void Start(){
        Rect screenRect  = new Rect(0, 0, Screen.width, Screen.Height); 
    }
    
    void Update{
        Vector3 screenPos = targetCamera.WorldToScreenPoint(objTrans.position);
        if(!screenRect.Contains(screenPos)){
            //do what you want
            Debug.log("Obj has gone out of screen...");
        }
    }

 

判断物体是否在摄像机内

标签:style   blog   io   color   ar   os   sp   div   on   

原文地址:http://www.cnblogs.com/waterdragon/p/4088949.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!