Search Unity

Ortho Camera ViewPort Rect quirkiness

Discussion in 'Editor & General Support' started by littlelingo, Dec 29, 2006.

  1. littlelingo

    littlelingo

    Joined:
    Jul 18, 2006
    Posts:
    372
    Hiya,

    I am creating and attaching a camera to a GO as well as changing its' viewport size via script but am getting quirky results. Here is the code:

    Code (csharp):
    1. var camObj : GameObject = new GameObject("camHolder");
    2. camObj.transform.parent = gameObject.transform;
    3. camObj.transform.localPosition = Vector3(0,175,0);
    4. camObj.transform.Rotate(90,0,0);
    5.    
    6. var cam : Camera = camObj.AddComponent(Camera);
    7. cam.rect = Rect(.78,.68,.98,.98);
    8. cam.isOrthoGraphic = true;
    9. cam.orthographicSize = 100;
    10.  
    The GO and camera are created just fine but the viewport rect is not setting to exactly what I am specifying. The minX and minY are setting correctly but the xMax and yMax are consistently off (1.76 and 1.66 respectively).

    Does anyone have any ideas?

    Thanks!

    -- Clint
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    the parameters of the rect constructor are width / height. Not xmax and ymax.
     
  3. littlelingo

    littlelingo

    Joined:
    Jul 18, 2006
    Posts:
    372
    Thanks Jo, just me being foolish.

    -- Clint