Skip to content

Commit

Permalink
@icon larger than 32x32 warning
Browse files Browse the repository at this point in the history
Warn user of `@icon` sizes larger than 32x32. This resolution is good
for hiDPI displays; higher resolutions effect performance.
Make mention of this in the docs as well.
  • Loading branch information
souplamp committed Dec 1, 2022
1 parent 7f8ecff commit 873bb30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4144,6 +4144,9 @@ Ref<ImageTexture> EditorNode::_load_custom_class_icon(const String &p_path) cons
Ref<Image> img = memnew(Image);
Error err = ImageLoader::load_image(p_path, img);
if (err == OK) {
if (img->get_size() > Size2(32, 32)) {
WARN_PRINT_ONCE("The class icon '" + p_path + "' is larger than the recommended size of 32x32. This can cause performance issues.");
}
img->resize(16 * EDSCALE, 16 * EDSCALE, Image::INTERPOLATE_LANCZOS);
return ImageTexture::create_from_image(img);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/doc_classes/@GDScript.xml
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@
[codeblock]
@icon("res://path/to/class/icon.svg")
[/codeblock]
[b]Note:[/b] Only the script can have a custom icon. Inner classes are not supported.
[b]Note:[/b] Only the script can have a custom icon. Inner classes are not supported. The recommended icon size is 32x32, as this resolution looks good on hiDPI displays (but higher resolutions can cause performance issues).
</description>
</annotation>
<annotation name="@onready">
Expand Down

0 comments on commit 873bb30

Please sign in to comment.