-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
base: master
Are you sure you want to change the base?
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
).
doc/classes/Camera2D.xml
Outdated
<member name="limit_rect_to_viewport" type="Callable" setter="" getter="get_limit_rect_to_viewport" default="Callable()"> | ||
A tool button that snaps the limits to the viewport. | ||
In the editor, pressing the button will make [member limit_left] and [member limit_top] become the global position of the camera, and [member limit_right] and [member limit_bottom] become the global position plus the size of the viewport. | ||
[b]Readonly:[/b] Since this is a tool button, it is read-only and trying to set the value of this property will trigger an error. | ||
</member> |
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.
I suspect we don't want to add/bind such button as a property with PROPERTY_HINT_TOOL_BUTTON
... Probably should be instead added using an EditorInspectorPlugin like e.g. Edit Region
button for Sprite2D etc.? 🤔 cc @KoBeWi
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.
Yeah inspector plugin would avoid adding a property. The property is not needed for anything.
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
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.
Don't forget to cleanup the commits, see the docs (there should be a single commit with descriptive title).
There's no rush to do that until this is ready to be merged though |
Thanks for informing that again but I've known this rule but I prefer to squash them until the final determination from you are almost fine to the pr. (except that sometimes there needs small tweaks after the determination is decided...) Squashed for the first time. There will be continuing commits, but who knows... |
a1e75ff
to
8bd214c
Compare
Is there still any use for Also the default rectangle functionality has weird interactions with camera. godot.windows.editor.dev.x86_64_9oHQES4Kh0.mp4Trying to move the rect in Select mode will instead move the view. It's not something very bad, but a proper editor for the limits would be better. |
If you disable it the camera can go anywhere without limits, even on single axis the camera can move to any x/y position over 100000000 pix. Basically it's kinda useful in this case... Btw the problem in the video has been fixed |
8bd214c
to
e736e1c
Compare
There is a visible jump when dragging after resizing: 6WxRMFT5Sb.mp4Also the camera can be selected by clicking inside it's rect. With camera using default limits, it means that clicking anywhere will select it.
Not sure if going beyond 10000000 is a realistic use case. |
Fixed (maybe).
I'm planning to propose a new pr to disallow all canvas items locked in the editor to be selectable, so basically I'm not considering fixing this. |
Creating Camera2D via right-clicking in the editor will result in awkward limits: sxb8JjFov3.mp4 |
Reviewed what I made, I think I have to make a new shortcut for moving the rect: |
…t and left mouse only to remove the camera itself
If you hold Ctrl before dragging the rect, it will start rotation instead. Also the corner text is visible even if limits are disabled. I still think that using rect for camera is not a very good idea. Now that you added a plugin, you can implement custom resizing functionality. The yellow lines that draw when |
You missed a key condition: In moving mode. So if you are using default mode then yes it will rotate the rect. As for the text, it will be fixed soon
Thanks for noting, but I don't think it a good practice to remake a wheel to resize the rect in an plugin. At least it's quite time-consuming for me to do research on how to make a new dragging system. |
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.* Added a button(Will be implemented in a continuation in the future)Snap Limit to Viewport
, on which you click will snap the top-left limit to the global position of the camera 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