-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
C# assigning a default value to an exported custom resource property will cause error #80175
Comments
Cannot confirm on v4.2.dev.mono.custom_build [f9f5041]. Building, adding the script to a node and running it all work just fine. |
I just tried official v4.2.dev2 and the issue still exists. I also tried v4.2.dev.mono.custom_build [eb4301b] later and the issue remains. |
This issue will not happen for me if I change "MyResource" to "AResource", which seems to be relevant to the order of reloading the scripts . Additionally, If a scene containing MyNode has been opened in the editor, the issue also disappears. |
Bumping this since I've stumbled upon this same issue as well on 4.1 and also reproduced it when running 4.2 from source (roughly same steps as above). I did a bit of debugging to see if I could see anything obviously wrong, but I'm not really familiar enough with the engine code to say for sure what's expected and not in this scenario. At a glance, the problem seems to be caused by the fact that the type for the member script (MyResource) will be added to the ScriptTypeBiMap during the default intialization of the owner script (MyNode), and then the same will be attempted when parsing the script for MyResource itself hence the double inserstion error. Seemingly MyResource will also linger in the map and cause other issues down the line when attempting to unloading the project assembly as mentioned by dasasdhba. I'm attaching my minimal project as well in case it helps with reproducing the issue. |
Just for tracking: Stumbled on the same problem (in 4.1.1) but commented on a different issue: #78513 (comment) Also, for reproduction: Running this for the first time seems to work fine, the issue only occurs when making code changes and building. (At least that's how it was in my project, haven't tried the project from the comment above.) Nice to see a PR addressing this! |
I am also experiencing this on For me, it's happening even when I set the default values in the object's constructor rather than in the field declaration. |
Commenting again to add, I'm not sure if they're related, but the export values in my scenes keep getting randomly nulled out. |
EDIT: I'm also getting this #79519 frequently, and after reading through that suspect this is the underlying issue with what I've got happening below. I'm seeing the same behaviour as @cjohnson57 in v4.2.stable.mono.official [46dc277] (the argument exception and also the export values getting nulled out randomly) If it's useful info, I started seeing this after upgrading the my project to v4.2.stable.mono.official [46dc277] and adding in a script based on a generic base-class. Structure I have is;
interestingy i've not seen the Full output log;
|
Appreciate everyone's work to get this fixed! This is a huge boon |
Godot version
v4.1.stable.mono.official
System information
Windows 10
Issue description
If you assign a default value to an exported custom resource property just like this:
Then you will get an editor error just as follows when building the solution:
By the way, rebuilding again without restarting the editor at this time will also cause
.NET: Failed to unload assemblies
issue.I think the editor should at least push a clear warning instead of throwing an error like this so that I have to restart the editor even if this behavior is not allowed.
Steps to reproduce
MyResource.cs:
MyNode.cs:
Building a project with these two cs scripts will cause editor error mentioned above.
Minimal reproduction project
gdcsharp-customresource-issue.zip
The text was updated successfully, but these errors were encountered: