Copy/Paste scripts

Hi all ! I’m just starting my canvas dive (I’m a very very junior)

My question is the following - is it possible to simply copy scripts from projects and include them in your html file?

Hi @Seventh_Space and welcome,

If you are talking about copying PlayCanvas scripts from one project to the other, sure just right click on the script asset, then copy and then right click on the destination project’s assets panel and paste.

If you are talking about including generic JS scripts from external websites, that can work too. Create a new PlayCanvas script asset, open it and replace the boilerplate code with your JavaScript code.

All PlayCanvas scripts assets are added to the index.html on runtime.

You can specify their loading order by going to your project settings and selecting the Scripts Loading Order view.

Hello Leonidas! Thanks for the answer. The project I’m meeting with uses old recipes and there is no way to get acquainted or fork the project for editing, but it is possible to view the code in the code viewer .
And so I think it’s possible to manually copy the code and create script files.

I’m talking about this project PlayCanvas 3D HTML5 Game Engine

Maybe there is a way to get it?

Hi @Seventh_Space! I’m be able to copy and paste the code from the scripts. Do you have a problem with that?

Greetings ! There are no problems with copy-paste, I’m interested to understand if I’m going in the right direction)

Normally there is a download button on the right side of the screen when you click on a script asset. I think because this project uses a deprecated scripting system, the download button is not available here.

1 Like

That project is using an older version of the scripting system that is no longer supported hence the warning:

If you want to use script from this project, you will have to port it over to the new scripting system format and style.