-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Auto resize custom class category icon in inspector. #71817
Auto resize custom class category icon in inspector. #71817
Conversation
editor/editor_inspector.cpp
Outdated
img.instantiate(); | ||
Error err = ImageLoader::load_image(icon_path, img); | ||
if (err == OK) { | ||
img->resize(16 * EDSCALE, 16 * EDSCALE, Image::INTERPOLATE_LANCZOS); |
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.
The fix looks good, my only doubt is whether it's fine to hardcode 16 here, or if that's something we can read from the editor theme?
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'm not sure, I just copy it from editor_node.h
:
Ref<ImageTexture> EditorNode::_load_custom_class_icon(const String &p_path) const {
if (p_path.length()) {
Ref<Image> img = memnew(Image);
Error err = ImageLoader::load_image(p_path, img);
if (err == OK) {
img->resize(16 * EDSCALE, 16 * EDSCALE, Image::INTERPOLATE_LANCZOS);
return ImageTexture::create_from_image(img);
}
}
return nullptr;
}
EDSCALE
is a macro that get editor scale, I think the hardcode 16 is a base size, and the real icon size can be auto scale by editor setting.
Same as #71818, I'm not sure why we resize when we can just render it at the size we want. |
64c0c98
to
6ca1a9c
Compare
Thanks for your contribution! I've incorporated all your work in #75472, so this is superseded now. You are properly credited in the relevant commit. |
Before:
After:
Fixed #68962.