Godot Version
4.6.1
Question
I am relatively new to Godot, but I work professionally in .NET. I am trying to learn by making a game where the goal is not a specific game vision, but to learn about the systems, how to make them generic or moddable, etc.
I have a habit of separating different logical units to separate .NET projects, which then allows them to be reused, not be cluttered, have more manageable unit tests, etc. With this in mind, I want to have a set of separate scenes that could then be used in other games. For example, a generic dialog component, with its TSCN and CS files that I could use across multiple games.
Is there a way to cleanly separate these into a separate Godot project, and then reference and use from another? I don't mind runtime loading of scenes if necessary, but I want to avoid any git tomfoolery like submodules, etc.
Best to make plugins for everything you plan to reuse. Then you can git submodule them if you must. Other than that - copy-paste.
1 Like
As Normalized mentioned you can use a plugin and reuse it as needed. This is probably the easiest if you plan on doing a lot of work in the scene editor.
Alternately you can create a project with the reusable components and export it to a pck file which you could then just include the pck files in any project you wanted to use the assets.
Alternately there’s the hard way, if you don’t mind manually coding your ui it’s easy enough to just create a traditional class library with your custom controls, and the use that in any project but you won’t have access to the scenes and controls in the scene editor. You also have to remember to store your icons as embedded resources, so they can be loaded at runtime. While you loose the ability to work in the scene editor with the controls you do gain the ability to have parameters in constructors.
Third way would be to design your scene, set it as an embedded resource, and then create a wrapper class instead of directly attaching a script to the scene, use the wrapper class to instantiate the scene and load any icons from embedded resources that are needed for the scene.
Both of these methods would allow using the objects as you would a regular class library.
I currently have a sample solution doing both the above, and would upload it but it seems zip files are not allowed.