-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Add Gradient resource preview generator #60395
Add Gradient resource preview generator #60395
Conversation
0320c6d
to
64b3d2f
Compare
How does it look when the inspector is narrower? |
@clayjohn It fills the width of the preview space. GradientTexture1D also does this. |
@@ -90,7 +90,8 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const | |||
if (p_preview.is_valid()) { | |||
preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox(SNAME("normal"))->get_default_margin(SIDE_LEFT) + get_theme_constant(SNAME("hseparation"), SNAME("Button"))); | |||
|
|||
if (Ref<GradientTexture1D>(edited_resource).is_valid()) { | |||
// Ressource-specific stretching. | |||
if (Ref<GradientTexture1D>(edited_resource).is_valid() || Ref<Gradient>(edited_resource).is_valid()) { |
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.
It would be nice to make stretching be defined by EditorResourcePreviewGenerator instead of hardcoding the resources, so that plugins can add stretching previews for custom resources too. But that can be done in another PR.
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.
You're right, I thought of this too, but this PR is just for adding the preview. I actually plan to refactor the resource preview system (as there are also some other small issues) sometime in the following weeks, it's already on my to-do list :)
64b3d2f
to
a93834c
Compare
Thanks! |
This PR implements a resource preview generator for the
Gradient
resource, which is quite helpful when working withGradient
s separate fromGradientTexture1D/2D
. Having the resource expanded in the inspector takes up a lot of space and makes it more chaotic when you just wan't to see how the gradient looks like. (Also useful for saved gradient resources)Examples:
FastNoiseLite
CPUParticles2D/3D
Resource preview in FileSystem dock: