Add icon seems to be blank
Closed this issue · 6 comments
func _ready():
$Header/Value.icon = get_icon('Add', 'EditorIcons')
seems to return a blank icon
See updated README. 🙂
In short, this is meant to be used in editor plugins. Plain tool
scripts require more sophisticated approach, but relies on internal EditorNode
. And this won't work in a game/exported projects.
Here's a shorter version:
tool
extends Node2D
func _draw():
if Engine.editor_hint:
var editor_gui_base = get_tree().get_root().get_child(0).get_gui_base()
draw_texture(editor_gui_base.get_icon('Add', 'EditorIcons'), Vector2())
ok ty
@Xrayez wait do I have to draw the node or can I just set it?
@Shadowblitz16 the snippet above is just an easy way to showcase the feature, Control.get_icon()
returns a texture, so this can be used everywhere where Texture
resource is accepted. This includes draw_texture()
above and things like $Button.icon
, or even $Sprite.texture
.
@Xrayez I was just wondering because it still doesn't seem to work
@Shadowblitz16 try this minimal project editor_icon_in_tool_script.zip, this should work in editor:
Perhaps we have a misunderstanding here. If you run a project from within the editor, this is expected that this won't work, this only works directly in the editor. 😛
And this functionality is not dependent on the plugin in either case.
If this doesn't work in the editor when you switch to 2D tab, then that's indeed a bug. If so, then please provide exact Godot version you're using to debug this further.