Skip to content
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

Godot should pre-compile C# project on load to prevent scene data loss with collaborative workflow #90755

Open
HeavensSword opened this issue Apr 16, 2024 · 4 comments

Comments

@HeavensSword
Copy link

HeavensSword commented Apr 16, 2024

Tested versions

  • Reproducible in version 4.3 Dev 5 snapshot

System information

Windows 10 & 11

Issue description

I have been working on a personal project of mine using Godot 4.3 Dev 5 between two computers, my main desktop (Windows 10) and my laptop (Windows 11) using Git. The majority of my project is written in C# and feel like this may only affect C#.

What I have been noticing is that when I make substantial changes in classes that utilize Export vars and resources on one machine, when I pull latest on Git on the other machine and load the project, Godot hasn't compiled the new changes and therefore cannot find objects and variables that the Scene is expecting as attached to parent nodes.
So what it ends up doing is removing the references and paths to these Nodes which in turn can cause data loss if you aren't paying attention. A workaround I have found is to look at my Git changelist, revert those tscn files that should not have been changed, and return to Godot and tell it to reload those files from disk.

If my assessment of this issue is correct, then I believe what could fix it is to have Godot try to compile the C# project before loading up the Scene files (and potentially other file types that might benefit from a pre-compile). This should ensure everything is synchronized before-hand.

Steps to reproduce

  • Create a project with a .NET build of Godot.
  • Create a C# script and inherit from something like Control. (I'm sure other types will work)
  • Create a new scene and add an instance of that node and attach the script
  • Save all and commit it to Git
  • On a different machine, pull latest, and load up the project
  • Alter the C# script so that it has new Export vars
  • Add new nodes of those Export types to the scene and then attach them to your parent node (the one created on the 1st machine)
  • Save the project and commit to Git
  • Return to the 1st machine and pull latest
  • Load up the project and see if Godot fails to find the changes and children paths created on the 2nd machine. (You should also see the warning in the Inspector that you may need to recompile C#)

Minimal reproduction project (MRP)

I can make a MRP if necessary, though I believe the steps above should be enough to reproduce the issue.

@ryevdokimov
Copy link
Contributor

ryevdokimov commented Apr 16, 2024

Related: godotengine/godot-proposals#849, godotengine/godot-proposals#2920

I had a similar issue for a project that required the C# solution to be compiled for a bunch of tool scripts, so I ended up doing a work around.

The "BuildProject" method in the editor build panel is exposed, so you can make a GDScript EditorPlugin that calls it when your project is opened for the first time.

@HeavensSword
Copy link
Author

Related: godotengine/godot-proposals#849, godotengine/godot-proposals#2920

I had a similar issue for a project that required the C# solution to be compiled for a bunch of tool scripts, so I ended up doing a work around.

The "BuildProject" method in the editor build panel is exposed, so you can make a GDScript EditorPlugin that calls it when your project is opened for the first time.

Ok, that sounds like an excellent work around for now; I'll give that a shot, thanks!

@HeavensSword
Copy link
Author

@ryevdokimov

Sorry, I'm still a bit new to Godot. How would I access the BuildProject method? From "get_editor_interface" ?

@ryevdokimov
Copy link
Contributor

You don't. I should have explained that it's exposed, but not part of the regular API, it's a function of the build panel node in the editor.

You have to get that node to call the function. The way I did it is to loop through basically all the nodes in the editor to find the node via: child.has_method("BuildProject").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants