I have project A and project B.
It is necessary to load the scene from A to B in realtime in the simplest way possible.
Also need to repeat this in the completed builds. From build A, load the scene into build B.
Are there any ideas about this?
I was thinking of putting the whole scene into a template, loading the template json’s and trying to restore the scene from this data, loading each asset separately.
What do you mean in code? Are you talking about at runtime? It is potentially possible to merge two built projects together but will require some custom code and also assumes that you are self hosting.
If you download a published build and look through the boilerplate, you can see how it is all put together in terms of add and loading assets.
In theory, it would be possible to take another project’s assets and scenes and load them with another build.
However, if you do go down this route, it is not an officially supported feature so it would be down to you to work out how it would all be handled.
Why does it have to be separate projects? Could you not have it all in one project and only load the assets you need for each scene and unload anything you don’t need?
We had some success in the past loading a scene from one project to the other. That involved in short:
Load all assets from remote project into base project, by parsing the config.json of that project.
After all assets have been loaded, parse the [sceneId].json from the remote project, load the scene and append the resulting hierarchy to the base project scene.
It required to write some methods of our own that mimicked how the PlayCanvas engine loads a project/scene.
I’d not recommend this as an approach though if you can do without this, since it’s not a path that is maintained/supported by PlayCanvas.
“Why does it have to be separate projects? Could you not have it all in one project and only load the assets you need for each scene and unload anything you don’t need?” - Lots of projects, maybe 50+ or even more, lots of different people working on them, it’s easy to break
Fearing breakdowns, it was decided to separate the projects.
Project A is the master project, it contains all the code.
Project B - contains mainly content and configuration files
Project C - contains mainly content and configuration files
There are many such projects as B and C.
Project A should be able to load project B or C or whatever.
Project A - main project, other projects - contain content.
Project A is one, other projects - 50+ or more.