You must use a FileDialog node. When using plugins, dialogs must be child of a specific node called the “base control”, I think it’s what makes them take the editor theme as well. Then signals are used.
var _file_dialog
func _enter_tree():
add_tool_menu_item('Find Texture Borders', self, '_do_work')
_file_dialog = FileDialog.new()
_file_dialog.mode = FileDialog.MODE_OPEN_FILE
_file_dialog.access = FileDialog.ACCESS_RESOURCES
# ... more config
_file_dialog.connect("file_selected", self, "_on_FileDialog_file_selected")
var editor_interface = get_editor_interface()
var base_control = editor_interface.get_base_control()
base_control.add_child(_file_dialog)
# Other setup code...
func _exit_tree():
# Cleanup
_file_dialog.queue_free()
func _do_work(ud):
_file_dialog.popup_centered_ratio()
func _on_FileDialog_file_selected(path):
var texture = load(res_path)
# Continue work using selected path
Worked perfectly! I could never have done it alone!
I was curious about the nomenclature you used in “_file_dialog”, I think I will adopt. Where did you see?
I tried to implement this to my program, and Godot told me that get_editor_interface isn’t defined. I did some searching and found that it can only be used if you’re using plugins. Do you need plugins to let the user upload files to the exported product, or can it be done without them? If you need them, how do you implement them, and what exactly do you need? Could you please point me to some tutorials where i could start? I tried to look something up, but it’s all very confusing, i have no idea where to start…