Created
May 6, 2024 23:46
-
-
Save williamd1k0/0a01adc4f163b52d3300b5b6c481f08c to your computer and use it in GitHub Desktop.
Helper Texture class to use Godot Editor icons in plugins, such as main screen plugins.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tool | |
class_name EditorIconTexture | |
extends AtlasTexture | |
var icon :String: | |
set(val): | |
icon = val | |
_update_icon.call_deferred() | |
func _init(): | |
_update_icon.call_deferred() | |
func _update_icon(): | |
atlas = EditorInterface.get_editor_theme().get_icon(icon, "EditorIcons") | |
region = Rect2i(0, 0, atlas.get_width(), atlas.get_height()) | |
func _get_property_list(): | |
return [{ | |
"name": "icon", | |
"type": TYPE_STRING, | |
"usage": PROPERTY_USAGE_DEFAULT, | |
"hint": PROPERTY_HINT_ENUM_SUGGESTION, | |
"hint_string": ",".join(EditorInterface.get_editor_theme().get_icon_list("EditorIcons")) | |
}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
editor-icons.mp4