Search Unity

UnityEngine.Rect.left' is obsolete: use xMin ???

Discussion in 'Scripting' started by noflyzone, Aug 29, 2011.

  1. noflyzone

    noflyzone

    Joined:
    Nov 22, 2010
    Posts:
    43
    public Rect AreaRect;


    void Start()
    {

    AreaRect=new Rect(100f, 300f, 160f, 28f);

    }

    void OnGUI()
    {

    GUILayout.BeginArea(new Rect(AreaRect.left,AreaRect.top+AreaRect.height, 160f, 256f));

    GUI.BOX(new Rect(10,10,200,120),"Tips...");

    GUILayout.EndArea();

    }


    **warning CS0618: `UnityEngine.Rect.left' is obsolete: `use xMin'???**
    **warning CS0618: `UnityEngine.Rect.top' is obsolete: `use yMin'????**

    The tips, how to solve it?
     
    Last edited: Aug 30, 2011
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
  3. noflyzone

    noflyzone

    Joined:
    Nov 22, 2010
    Posts:
    43
    what ? Why?I did not make anything wrong
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The docs explain how to use Rect and what the properties are. Please click on the link I provided and read them.

    --Eric
     
  5. Ntero

    Ntero

    Joined:
    Apr 29, 2010
    Posts:
    1,436
    I'd say use xMin/yMin, even the warning gives solutions on how to solve it.

    It may be a slight logic refactoring, but left is deprecated and could be removed or broken at any time.
     
  6. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    The reason for this change is that the top and bottom parameters were a bit confusing. The Y coordinates increase in different directions depending on what you are doing (eg, for GUI they increase downwards whereas for mouse coordinates, they increase upwards). Therefore, the top field didn't always correspond to the visual top of the rectangle but rather the minimum Y coordinate. This is what prompted the change to yMin and yMax and the xMin and xMax were introduced for consistency. I have filed a documentation bug about adding better notes on this to the Rect script ref page, and the changes should be available in the next version of Unity.
     
  7. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    This is now fixed in source and will be available soon.