Limit @export_file to only choose files in a specific directory

Godot Version

v4.2.2.stable

Question

I want to export a .tscn file in the path “res://scenes/enemies” so i can make a scene that uses the chosen enemy scene and instantiates a certain number of enemies of the chosen type, and i can’t figure out how. I know the FileDialogue class can specify which directory to choose from with root_subfolder, and @export_file can take the suffix of the file. I need this for developing the game, not for the player to use. How can i do this?

edit: I am aware that I can use @export_enum for this, but that would take a lot of time to setup, especially as i continue adding enemies. I’m hoping there’s a better way to do that

You can’t restrict @export_file to a specific folder, but if you set the default value to be the folder you want, it’ll start the dialogue in the folder:

@export_file("*.tscn") var file_path: String = "res://scenes/enemies/"

Thank you so much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.