Cross-project loading

Hi :slightly_smiling_face:

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.

To load a scene from another project is not possible.

You can create a template of the scene in project A, then use Editor copy and paste the template asset into project B (Assets | Learn PlayCanvas)

This will also copy all the assets in the template across as well.

1 Like

Yes, this is almost what you need, almost :slight_smile:
Is there an easy way to repeat this in code ?

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?

1 Like

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.

3 Likes

“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 :slight_smile:
Fearing breakdowns, it was decided to separate the projects.

In which case, it sounds like it would be easier to move between URLs instead of loading/unloading scenes?

1 Like

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.

Yes, that’s pretty much what I was thinking…
So it’s possible :slight_smile: Thanks :slight_smile:

1 Like