コード例 #1
0
    void LateUpdate()
    {
        //求阴影产生物体的包围盒
        Bounds b = new Bounds();

        for (int i = 0; i < _shadowCasterList.Count; i++)
        {
            if (_shadowCasterList[i] != null)
            {
                b.Encapsulate(_shadowCasterList[i].bounds);
            }
        }
        b.extents += Vector3.one * boundsOffset;

//        Bounds bc = new Bounds();
//        for (int i = 0; i < _boxCasterList.Count; i++)
//        {
//            if (_boxCasterList[i] != null)
//            {
//                bc.Encapsulate(_boxCasterList[i].bounds);
//            }
//        }
//        bc.extents += Vector3.one * boundsOffset;
#if UNITY_EDITOR
        _boundsCollider.center = b.center;
        _boundsCollider.size   = b.size;
#endif
        //根据mainCamera来更新lightCamera和projector的位置,和设置参数
        ShadowUtils.SetLightCamera(b, _lightCamera);
        _projector.aspectRatio      = _lightCamera.aspect;
        _projector.orthographicSize = _lightCamera.orthographicSize;
        _projector.nearClipPlane    = _lightCamera.nearClipPlane;
        _projector.farClipPlane     = _lightCamera.farClipPlane;
    }
コード例 #2
0
ファイル: ShadowProjector.cs プロジェクト: hw233/mmoclient
    void LateUpdate()
    {
        //求阴影产生物体的包围盒

        /*Bounds b = new Bounds();
         * for (int i = 0; i < _shadowCasterList.Count; i++)
         * {
         *  if(_shadowCasterList[i] != null)
         *  {
         *      b.Encapsulate(_shadowCasterList[i].bounds);
         *  }
         * }
         * b.extents += Vector3.one * boundsOffset;
         #if UNITY_EDITOR
         * _boundsCollider.center = b.center;
         * _boundsCollider.size = b.size;
         #endif
         * //根据mainCamera来更新lightCamera和projector的位置,和设置参数
         * ShadowUtils.SetLightCamera(b, _lightCamera);*/

        if (_mainCamera == null)
        {
            _mainCamera = Camera.main;
        }
        if (_mainCamera == null)
        {
            return;
        }
        ShadowUtils.SetLightCamera(_mainCamera, _lightCamera);
        _projector.aspectRatio      = _lightCamera.aspect;
        _projector.orthographicSize = _lightCamera.orthographicSize;
        _projector.nearClipPlane    = _lightCamera.nearClipPlane;
        _projector.farClipPlane     = _lightCamera.farClipPlane;
    }
コード例 #3
0
    void LateUpdate()
    {
        //calculate bounding box of the shadow caster
        Bounds b = new Bounds();

        for (int i = 0; i < _shadowCasterList.Count; i++)
        {
            if (_shadowCasterList[i] != null)
            {
                b.Encapsulate(_shadowCasterList[i].bounds);
            }
        }
        b.extents += Vector3.one * boundsOffset;
#if UNITY_EDITOR
        _boundsCollider.center = b.center;
        _boundsCollider.size   = b.size;
#endif
        //according to the mainCamera,updating position of lightCamera and projector
        ShadowUtils.SetLightCamera(b, _lightCamera);
        _projector.aspectRatio      = _lightCamera.aspect;
        _projector.orthographicSize = _lightCamera.orthographicSize;
        _projector.nearClipPlane    = _lightCamera.nearClipPlane;
        _projector.farClipPlane     = _lightCamera.farClipPlane;
    }
コード例 #4
0
 void LateUpdate()
 {
     ShadowUtils.SetLightCamera(_mainCamera, _lightCamera);
 }