You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB
GDScript

2 years ago
@tool
extends PanelContainer
var resource_picker: EditorResourcePicker
signal save_request
func _ready() -> void:
if get_tree().edited_scene_root and get_tree().edited_scene_root.is_ancestor_of(self):
return
resource_picker = EditorResourcePicker.new()
%IconContainer.add_child(resource_picker)
resource_picker.base_type = "Texture2D"
resource_picker.size_flags_horizontal = Control.SIZE_EXPAND_FILL
resource_picker.resource_changed.connect(func(a): save_request.emit())
2 years ago
func get_data() -> Dictionary:
var data := {element = %LineEdit.text}
if resource_picker.edited_resource:
data.icon = resource_picker.edited_resource.resource_path
return data
2 years ago
func get_data2() -> Dictionary:
var data := get_data()
if "icon" in data:
data.icon = load(data.icon)
return data
2 years ago
func set_data(data: Dictionary):
%LineEdit.text = data.element
if "icon" in data:
resource_picker.edited_resource = load(data.icon)
2 years ago
func delete() -> void:
queue_free()
save_request.emit()