-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve usability of Camera2D
#101427
Improve usability of Camera2D
#101427
Conversation
While I like the idea of making editing the camera limits a more interactive experience, I very much dislike the change of the default limit. I didn't try it out, but wouldn't this effectively make a camera that gets added to a node non-functional (as in, it doesn't move in any direction) unless you enlarge the limit rectangle? This would be a bad user experience, and lead to lots of confusion. Edit: This is also why the unit tests fail. Instead, I propose a Boolean property on the camera to enable/disable the limits, and have it disabled by default. |
Good idea, but the reason why I changed the default is that users couldn't see and drag the rectangle as it was too large to find the dragger if we still use default 1000000 rectangle, unless they change the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Now the default limit will not be +/-1000000, instead, the top-left will be (0, 0) while the bottom-right will become (viewport_w, viewport_h)
This is compatibility breaking change. Properties set to their default values are not being saved to the resource (scene) file, meaning if someone was using Camera2D with its default limits unchanged, then such limits are not saved within the scene file containing the Camera2D. After this change loading such scene would create the Camera2D with the new defaults, resulting in changed behavior (likely breaking user's project).
Camera2D
51572e1
to
908a392
Compare
I reverted the change of default value. What takes the place of the previous change has been added in the top post. |
Oh, haven't thought about that new bool suggestion previously, but
So the limits should be enabled by default to preserve the current behavior. Regarding the |
8ff4594
to
cfeca3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT no longer breaks compat. 👍
- Added
limit_disabled
, which allows the camera focus to move anywhere. Set tofalse
by default.
As already mentioned in #101427 (comment), please rename it to limit_enabled
and swap its default value/checks (even for the Camera2D itself there are already properties like enabled
, drag_{horizontal|vertical}_enabled
, {position|rotation}_smoothing_enabled
).
72578e4
to
acdcc0f
Compare
acdcc0f
to
c8aa829
Compare
Making the plugin of it seems a bit time-costing so I don't plan to add it in this pr. However, once i have available time for it, I'll try to add it in a continuation of this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested a little in action, AFAICT works as expected. Overall LGTM, not sure about the exposed editor_draw_limits_color
, see the comment I've added.
scene/2d/camera_2d.cpp
Outdated
@@ -937,6 +1014,7 @@ void Camera2D::_bind_methods() { | |||
ADD_GROUP("Editor", "editor_"); | |||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_draw_screen"), "set_screen_drawing_enabled", "is_screen_drawing_enabled"); | |||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_draw_limits"), "set_limit_drawing_enabled", "is_limit_drawing_enabled"); | |||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "editor_draw_limits_color"), "set_limit_drawing_color", "get_limit_drawing_color"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For other reviewers: note there are other debug drawing colors which are still hardcoded, so this one being customizable/exposed is inconsistent in that regard. I'm not sure whether this is fine as is or if maybe something needs to be done about it.
Line 375 in 1b7b009
Color area_axis_color(1, 0.4, 1, 0.63); |
Line 420 in 1b7b009
Color margin_drawing_color(0.25, 1, 1, 0.63); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's to be made configurable, the limits color should be configurable in the editor settings rather than a per-node property, unless there's a demonstrable need for it to be configured on a per-node basis (like collision shapes).
That said, I would prefer we don't expose a setting at all if no need has been expressed by users beforehand.
c8aa829
to
a1e75ff
Compare
48114d5
to
2c0a52a
Compare
I think it may be enough to open separate issue for rotated camera dragging and leave this out of scope of current PR. |
2c0a52a
to
b5b41cd
Compare
@arkology How did you trigger this error thrown at that time? Maybe I need details about it so that I can locate where the problem happened. |
@Lazy-Rabbit-2001 I didn't pay attention what exactly caused error. And I can not reproduce it now. |
|
Perhaps you triggered an edge case that is extremely difficult to track.... |
You still didn't remove TOOLS_ENABLED checks from the plugin. |
Sorry but I was so busy that I had no time available for it. I'll remove the rest one tonight |
b5b41cd
to
44f00cc
Compare
44f00cc
to
5ca70d8
Compare
Thanks! |
Bug - both yellow and orange rectangles are camera limit. The real camera limit is yellow one. UPD 2025/03/18 |
Hope he will fix this, as I've checked a bit he has established a new and unique dragging system for |
Implements and closes: godotengine/godot-proposals#11527
Changes:
* Now the default limit will not be +/-1000000, instead, the top-left will be (0, 0) while the bottom-right will become (viewport_w, viewport_h)limit_enabled
(true
by default), disabling which will allow the camera focus to move anywhere.Snap Limit to Viewport
, on which you click will snap the top-left limit to theglobal position of the camera(0, 0) and the bottom-right limit to the global position plus the size of the viewport.editor_draw_limits_color
, which allows you to change the color of the limit rect.limit_*
variables.Issues