godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.89k stars 21.14k forks source link

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

Open HeavensSword opened 6 months ago

HeavensSword commented 6 months ago

Tested versions

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

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 commented 6 months ago

Related: https://github.com/godotengine/godot-proposals/issues/849, https://github.com/godotengine/godot-proposals/issues/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 commented 6 months ago

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 commented 6 months ago

@ryevdokimov

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

ryevdokimov commented 6 months ago

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").

BananaPuppy commented 3 months ago

Almost every push requires the people working on the project to get in vc and explain to one another how to setup the exports in parts of the project we are not responsible for working on, especially since we have embraced composition over inheritance. I love Godot, but this one issue is really disrupting the collaborative workflow and kind of defeats the purpose of vcs.