I'm trying to add an optional resource that can be specified in an importer as a preset to get around the shortcomings of the current preset system for imports mentioned here: https://github.com/godotengine/godot-proposals/issues/8350
Unfortunately, I cannot add an optional preset resource, as it seems impossible to have a resource type in the importer that can be set to null.
In this example, "preset_not_null" behaves as a resource and the editor allows users to specify a different resource or create a new one as normal. "preset_null", however just displays "" and clicking on the box does nothing, even though the hints are set up exactly the same.
If you right click and clear the preset_not_null, it will simply revert back to the default value.
I've also tried setting a "default_value" of Resource, which appears to work, until the .import file is read again, at which point there is an error parsing it and the import options are completely gone:
The errors are
Class 'GDScriptNativeClass' or its base class cannot be instantiated.
core\io\config_file.cpp:304 - ConfigFile parse error at res://levels/test_bspx.bsp.import:14: Can't instantiate Object() of type: GDScriptNativeClass.
Not setting the default_value isn't an option, as that errors out.
Steps to reproduce
Create an importer with a resource type in the importer options defaults, ex:
Note that if the default value is set to null, the property cannot be used as a resource. If a resource is added by default, setting the resource to null will cause the resource to go back to the default value.
Tested versions
v4.3.stable.official [77dcf97d8]
System information
Windows 10, Vulkan forward +, Nvidia 3070
Issue description
I'm trying to add an optional resource that can be specified in an importer as a preset to get around the shortcomings of the current preset system for imports mentioned here: https://github.com/godotengine/godot-proposals/issues/8350
Unfortunately, I cannot add an optional preset resource, as it seems impossible to have a resource type in the importer that can be set to null.
In this example, "preset_not_null" behaves as a resource and the editor allows users to specify a different resource or create a new one as normal. "preset_null", however just displays "" and clicking on the box does nothing, even though the hints are set up exactly the same.
If you right click and clear the preset_not_null, it will simply revert back to the default value.
I've also tried setting a "default_value" of Resource, which appears to work, until the .import file is read again, at which point there is an error parsing it and the import options are completely gone:
The errors are
Not setting the default_value isn't an option, as that errors out.
Steps to reproduce
Create an importer with a resource type in the importer options defaults, ex:
Note that if the default value is set to null, the property cannot be used as a resource. If a resource is added by default, setting the resource to null will cause the resource to go back to the default value.
Minimal reproduction project (MRP)
import_resource_null.zip