- Edited
I'm searching and failing to find anything. I'm creating a gdscript from code, but it doesn't show up in resources until I unfocus then refocus godot. It's not a huge deal, but it's a little awkward for something I want to release. Is there something I can call to get the file system to rescan and (re)load the generated script?
Here's what I'm trying which isn't working:
if !DirAccess.dir_exists_absolute(file_path.get_base_dir()):
DirAccess.make_dir_recursive_absolute(file_path.get_base_dir())
var file := FileAccess.open(data["script"], FileAccess.WRITE)
file.store_string(file_txt)
file.close()
print("Wrote to " + file_path)
EditorInterface.get_resource_filesystem().reimport_files([file_path])
The file is created and modified just fine. Like I said, the editor just doesn't pick up on the changes until I unfocus then refocus. That last line, EditorInterface.get_resource_filesystem().reimport_files([file_path])
just errors. It either gives me
Can't find file 'res://generated/name_of_file.gd'.
if it was just created, or
BUG: File queued for import, but can't be imported, importer for type '' not found.
if it's being updated.
I worry this may be too closely tied to ScriptEditor to do anything about. Oh how I loathe that class. It is a jungle of spaghetti.