-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exporting resource whose _init takes a parameter results in resource being null in scene startup #67059
Comments
Can confirm similar problem for 3.5.1 stable. In my case I was using custom resources in tool script and after reloading editor every resource becomes null for tool scripts. Seems related to #38222 and somewhat related to #37907 Maybe we need some warning about using _init with arguments, because it can lead to unexpected behavior. |
Just encountered this in 4.0 stable. Was really confusing to debug, as the error message in the debugger is just Could there be a warning in the GDScript editor instead that classes that extend resource aren't supposed to have constructor arguments in I have opted to create a static function |
The class is instantiated in the scene loader, so the function would need default values to work correctly if the |
I am honestly not sure how nodes and resources with This would be a lot easier to do if there was overloading for the Relevant proposals: godotengine/godot-proposals#1513 and godotengine/godot-proposals#5899 |
It would be best to at least warn the user that a resource requires a default constructor. |
Yes, as the related proposal godotengine/godot-proposals#5899 does |
Consolidating with godotengine/godot-proposals#5899. |
Godot version
v4.0.beta2.official [f8745f2]
System information
windows 10
Issue description
When attempting to export a resource whose _init function takes a parameter, that resource will be null when running the scene.
An error is also thrown when running the scene; _create_instance: Error constructing a GDScriptInstance.
Im not sure what the expected behaviour should be, but at least the error thrown in this case should be more descriptive, as currently it doesn't even point to a given resource being the issue, its stack trace leading to gdscript.cpp:183.
Steps to reproduce
Minimal reproduction project
ResourceExportTest.zip
The text was updated successfully, but these errors were encountered: