Is it possible to work on a scene separately in it’s own project environment and then transfer that scene over to another project? For example, if you wanted to create a character scene in a lightweight “workbench” type project and when it is ready, transfer it over to your main project. Sometimes I don’t want to open a large and complex project first - especially when experimenting.
Technically yes, scenes are nothing more than text files so you could do that. Of course, the issue is dependencies, which you would have to fix to properly import a scene from one project to another. So “transfering” may be done by moving the files and fixing some missing dependencies, or simply redo the work in another project once you know what to do.
I don’t think there’s another way to do so, but maybe someone will have a better idea.
Not that I’ve tried this, but from the worked I have done myself, if your scene has everything it needs to function by itself and all proper parts are transfered with it (scripts, models, textures, etc), I don’t see why not.
I usually make workbench scenes, but have done separate projects too. Like some cool character controller that I might want to reuse later for other projects too, could be a good idea to do like this.
Yup. I’ve done it more than once. You have two options.
Approach 1
Just drag-and-drop everything over between folders in your OS. When you go back to the project (you can do this while one or both projects are open) everything will load. A few caveats:
If you do not have the exact same directory (folder) structure in your new game, when you open up a scene it will not be able to find it’s scripts or resources. You will need to follow the prompts to fix dependencies.
If you have exported variables that contain other complex nodes that you want to keep intact, you need to open those scene first and fix their dependencies before opening the main scene. Same with resources. Failure to do this will result in all your references being wiped.
If you transfer something over that has an import script (like a model), you will need to go to the import tab and re-attach the script. Then you want to re-import and open this model first. The reason for this is if you open something that relies on this first, it will overwrite any changes or additions you made to the object post-import that relied on the import script. If this happens, just delete the dependent scene, open the thing it needs first, and then copy the dependent scene over again and re-open it.
Approach 2
Inside your first project, create an addons folder, and then a my_scene subfolder inside your first project.
Do all your work inside that my_scene folder. Sub directories, assets, sound, other nodes, resources, models, etc.
Copy the entire my_scene folder into your new project, inside the addons folder.
This method keeps all the relationships intact and means you don’t have to fix any relationships. Upside: If you want to change something in the source project, you just copy the folder over again when you make a change. Downside: Your game’s structure might be a bit more distributed.
I use Approach 1 when I’m copying something from a past project or tutorial over and integrating it into a game. I use Approach 2 when I’m creating components for my game. For example my Sound component handles all sound-related stuff. I’ve turned it into a plugin that has some autoloads and resources I have created for songs and sound effects. I track versions and my projects can just use whatever version I’m on.
I also have one for controllers (Gamepad, Mouse, Keyboard), video settings, interaction, UI (menus, splash screens, HUD), and a game template that pulls them all together. I’m currently working on one for Characters that allows me to drop 3D players and enemies into games without having to use Approach 1 so many times to move characters between games.
Yeah that’s my preference too. I also make sure my addon code never relies on code in my main game. That way I can drag and drop it into another game. Some of my addons do rely on one another though. For example my Camera addon relies on my Controller addon to get input for First Person camera movement.