You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
I would like to be able to quietly bail on importing a file after doing a bit of parsing.
In my project, I first look to see if a script is provided in the import options. If it's not there then I read the json file and look for a 'script' member. If neither of those exist, I would like to just skip the file without any errors.
If there is a way to do this, I cannot find it anywhere. If I return OK without saving, I get the cryptic error: core/os/file_access.cpp:671 - Condition "!f" is true. Continuing. If I return any other error code, I get the "import failed" message. I cannot find a way to silently bail on importing a file short of writing a blank file to the .import folder (gross.)
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Allow users to skip a file from the import(...) function. (If this already exists, let me know and I will open a docs proposal instead.)
I would propose one of two solutions: Allow the returning of OK without saving to "skip" a file. Allow the returning of ERR_SKIP to skip importing a file.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Example usage:
funcimport(source_file, save_path, options, r_platform_variants, r_gen_files) ->int:#Error...#read and parse json file return real errors if those fail# If it is a valid json, but doesn't have our script variable, then silently bail on the fileifnotjson.has("script"):return ERR_SKIP
...# save stuffreturn OK
I don't know enough about the back-end to comment there. The new "Keep File (No Import)" option could maybe be some help, but I don't actually know.
If this enhancement will not be used often, can it be worked around with a few lines of script?
An error can be returned and the console will just be spammed each time out leave and re-focus the editor. Not ideal, but things do keep working.
Is there a reason why this should be core and not an add-on in the asset library?
I think the code in question is in core.
The text was updated successfully, but these errors were encountered:
cgbeutler
changed the title
Allow EditorImportPlugin to skip files in import
Allow EditorImportPlugin to skip files in import()Apr 23, 2021
As for the md5 error printed out if you return OK without saving anything, looks like dest_paths get filled with what it thinks will be the path. Then later the md5's are generated, giving an error, since that path doesn't exist. This section does skip dest_paths if the extension is empty. Would need to also skip when it gets ERR_SKIP or something. https://github.com/godotengine/godot/blob/c7b97f077a0f62d9e280adbddddc901f35e4f40f/editor/editor_file_system.cpp#L1802-L1823
If not that, then the md5 section later could check for the file first or something. Regardless, that code seems like a decent entry point to figuring it out.
Describe the project you are working on
Json importer using gdscript's
EditorImportPlugin
Describe the problem or limitation you are having in your project
I would like to be able to quietly bail on importing a file after doing a bit of parsing.
In my project, I first look to see if a script is provided in the import options. If it's not there then I read the json file and look for a 'script' member. If neither of those exist, I would like to just skip the file without any errors.
If there is a way to do this, I cannot find it anywhere. If I return
OK
without saving, I get the cryptic error:core/os/file_access.cpp:671 - Condition "!f" is true. Continuing.
If I return any other error code, I get the "import failed" message. I cannot find a way to silently bail on importing a file short of writing a blank file to the.import
folder (gross.)Describe the feature / enhancement and how it helps to overcome the problem or limitation
Allow users to skip a file from the
import(...)
function. (If this already exists, let me know and I will open a docs proposal instead.)I would propose one of two solutions: Allow the returning of
OK
without saving to "skip" a file. Allow the returning ofERR_SKIP
to skip importing a file.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Example usage:
I don't know enough about the back-end to comment there. The new "Keep File (No Import)" option could maybe be some help, but I don't actually know.
If this enhancement will not be used often, can it be worked around with a few lines of script?
An error can be returned and the console will just be spammed each time out leave and re-focus the editor. Not ideal, but things do keep working.
Is there a reason why this should be core and not an add-on in the asset library?
I think the code in question is in core.
The text was updated successfully, but these errors were encountered: