Skip to content

Instantly share code, notes, and snippets.

@Invertex
Forked from williamd1k0/EditorIconTexture.gd
Created April 26, 2025 02:12
Show Gist options
  • Save Invertex/0b65d1ec987a66cf8fc4cee7c1aabc24 to your computer and use it in GitHub Desktop.
Save Invertex/0b65d1ec987a66cf8fc4cee7c1aabc24 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"))
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment