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?
what ? Why?I did not make anything wrong
The docs explain how to use Rect and what the properties are. Please click on the link I provided and read them.
–Eric
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.
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.
This is now fixed in source and will be available soon.