Search Issue Tracker
Fixed
Votes
0
Found in
5.1.0f1
Issue ID
699546
Regression
No
[Rect] Rect constructor argument names are confusing
I'm writing about rect class realization I believe rect constructor argument names are confusing and should be changed.
So this how current rect constructor looks in C#:
CSRAW class Rec(float left, float top, float width, float height)
And this how it should look according me:
CSRAW class Rec(float x, float y, float width, float height)
Justification:
For example I want to create new Rect.
1. Rect rect = new Rect(0 (left), 128 (top), 128 (width), 128(height))
2. So I should expect two possible results (if width goes down or it goes up)
a) Rect - left = 0, right = 128, top = 256, bottom = 128.
b) Rect - left = 0, right = 128, top = 128, bottom = 0.
Of course the right answer is A. However according the documentation picture (http://docs.unity3d.com/ScriptReference/Rect.html) the right answer is B. I know that this argument naming is came from OpenGl API orientation system, but usually user doesn't know this and it can be extremely confusing.
I also had some discussion with developers, so this is their thoughts:
@Mads Nyholm <mads@unity3d.com>
"I think we should simply change it to: Rect (float x, float y, float width, float height)
Internally is sets xMin, yMin, width, height.
The use of the properties left, right, top and bottom has been made obsolete a long time ago."
@richardf@unity3d.com
"I’d prefer (float xMin, float yMin, float width, float height) over that, but sure."
@Aras Pranckevicius <aras@unity3d.com>
"Yeah, the fact that we have two different coordiante spaces is confusing, isn't it.
Many things in Unity use "OpenGL like" coordinate space. For example, texture.SetPixel with (0,0) means "bottom left"; same with some coordinates like in Camera.ViewportToWorldPoint, where y=0 is "bottom", or with Input mouse coordinates, or camera viewport settings.
However! IMGUI (i.e. all the OnGUI stuff), and I think the 4.6 UI uses y=0 as "top".
To add to the confusion, the super-legacy GUITexture and GUIText components of course use y=0 at "bottom".
Fun :)
...I agree, renaming the arguments to be (x,y,widht,height) would make it less confusing. And also perhaps stating which parts of Unity use which coordinate conventions somewhere (see above) too."
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [UI Builder] Viewport's gizmos for Margin and Padding disappear when dragging to modify the value and the cursor leaves the Spacing section
- "Multiplayer Center" window does not reflect changes made in "Other Packages" section
- Crash on D3DKMTOpenResource when capturing with RenderDoc while GPU Skinning is set to GPU(Batched)
- Editing and saving Curve changes in UI Builder window throws multiple errors in the Console
- [UI Builder] Value is not selected when left clicking on Spacing/Border Widget values
Add comment