[SOLVED] Define Scenes In Engine Only Build

Hello,

I was just trying to convert an editor game into an engine only build. How would I define different scenes and change scenes in an engine only build?

1 Like

I’ve done something similar in the past, but it isn’t a small feat.

We’ve used the editor to build scenes, download the build and save it locally alongside with an engine only project. From there we will mimic what the Playcanvas loader does when it loads an editor scene, to load the scene file, scripts/assets to our project and append the new scene hierarchy.

If you would like to do this, a good starting point is to study how an exported build from the editor works. All the code you will need is in there.

Essentially @Leonidas, I just need to change the path to the images in my game locally once I have downloaded the exported build. Is that easier? The rest can remain as is.

Not sure if it is a small feat for you to build your game again using the engine directly, instead of the editor.

To change the image paths you could export the build and change manually your [scene].json file that contains the relative paths to your assets.

Of course if you know about servers and url rewrites, you could do that on the fly using server rules. But that requires special knowledge and I am not sure it serves your purpose here.

2 Likes

I think changing the scene json file would work just fine. Let me try it out and if I have any problems I’ll get back to you.

1 Like

That it isn’t @Leonidas :wink:

Knowledge which I do have, but as you correctly said, doesn’t serve my purpose.

Could you give me a short example of where to change the path?

2 Likes

@Leonidas, would I put in the path like so?

ldren":[],"position":[-580.5309856273565,305.6910037994385,0],"rotation":[0,0,0],"scale":[0.125,0.2,0.25],"components":{"element":{"enabled":true,"type":"image","anchor":[0.5,0.5,0.5,0.5],"pivot":[0.5,0.5],"text":"","key":null,"fontAsset":25835206

Replacing the numbers with the path?

This number.

And should it be in single quotes or not?

1 Like

No, I think you don’t have to change the [scene].json but the config.json file which defines all the resources required by this scene.

If you go in there you will see a number of urls that reference the local files folder. Try playing with those. Sorry can’t guide you more on this, it’s been a while since I’ve done that.

2 Likes

This is much easier. Thanks so much.

1 Like

@yaustar, since you were advising me to make my project a local project to put it on Koji, is this a temporary fix?

1 Like

IMO, not really. Scenes, and compressed textures, fonts, sprites etc aren’t easily editable from within the Koji tools. You would still have to export the files from the PlayCanvas Editor or external tools and upload to Koji (either via Git or copy and paste).

Eg. If I wanted to change the font from a Koji remixed project that used an exported PlayCanvas Editor build, how would I do that?

Edit: I’m not sure I said ‘local project’ in this context. I’m pretty sure I referenced being ‘engine only’ [SOLVED] Error Loading Asset When Project Is Downloaded

2 Likes

This is quite easy. Simply create a new text VCC in the Koji Editor, and upload your font there. Next, change the path in config to match the one from your VCC. That’s all. Now someone can change the font without doing any coding at all.

PlayCanvas doesn’t use the font file as is, it uses a signed distance field texture generated by an external tool. A tool that Koji don’t have as part of their tool suite.

So either:

  • The user has to download the tool from PlayCanvas’s GitHub, generate their font texture and upload the files
  • The original project on Koji has the tool uploaded as one of the project files and the font texture is generated as part of the build process making it much simpler to replace the font or create new ones
  • The user uses the PlayCanvas Editor to generate the font texture and downloads the texture file to upload to Koji
1 Like

I can download the tool on GitHub, and put it on Koji.

Bare in mind the experience that another user would go through. If they remixed your project, what can you do in your project to help them modify the game? Eg changing the font, how will they know what tool to use and what settings? How will they know how to add a new UI screen to the scene? Etc

1 Like

I’ve thought that out. I will be providing proper details in the README. Thanks for you help @yaustar and @Leonidas

@Leonidas and @yaustar could you please help me here - Change URL in config file to variable.

I’ve tried what you’ve suggested but it isn’t working.