Skip to content

Instantly share code, notes, and snippets.

@williamd1k0
Created May 6, 2024 23:46
Show Gist options
  • Save williamd1k0/0a01adc4f163b52d3300b5b6c481f08c to your computer and use it in GitHub Desktop.
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.
@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"))
}]
@williamd1k0
Copy link
Author

editor-icons.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment