Covert project between legacy and ordinary scripting

Hi I’m wanting to convert a project from new scripting to legacy - or copy all of the assets from one project to another. Are either of these things possible?

You’re the first person I’ve seen wanting to go in that direction. :slight_smile:

The best way to do it is to simply create a new project and reupload your assets. If you have a relatively small number of assets, this is a pretty quick operation. If you have a huge quantity, it can be a little more problematic. But you can download a project archive of the ‘new scripting’ project and do a search for all source assets and multiselect and drag/drop reupload in a single drag.

Yeah I kinda bit the bullet and went with the new scripting system. But I did find that the limitations around the editor mean that I’m having to edit all of the source code locally and then transfer it to PlayCanvas so I can get better intellisense etc.

I’m finding the new scripting system fine, like the way that attributes are defined etc but I am missing the constructor so I can setup things on entities that are not yet live in the hierarchy (like promises of data that need to be loaded etc). It would be really nice if you could add an event that is called when an entity is constructed but not made active - as this handles lots of interesting edge cases in several of the projects I’ve done recently. I find my self feeling like I’m bodging to get around the lack of a script constructor.

On that note, I think that the best way to do editing of the new stuff for me is to use something like VSCode or IntelliJ and transfer the files to you with a deployment. This could be easily supported on your end through the REST API I’d guess and then I could do my version control locally and move stuff around in the same way as I do for my none PlayCanvas related developments.

1 Like

FWIW, I’m the second person wanting to convert from the new scripting system back to legacy on an existing project. I’m new to Playcanvas so I though “hmm legacy doesn’t sound good” when reading the documentation. But after two weeks I think, maybe it should be renamed from “legacy scripting” to “professional scripting” :wink: Anyway I created the project with the new scripting system and now sort of regret it, because I need to go back to the legacy system.

The cloud workflow for scripts has the following drawbacks, especially for small teams:

  • we’re using Typescript and tslint to program the game logic, this isn’t available in the online editor

  • we’re using VSCode or similar IDEs because they can be enhanced with plugins

  • we definitely need version control for branching, merging and rolling back mistakes, also when bugs happened the version history is necessary for finding the bug (when did the bug first happen etc…)

  • there’s no way to upload scripts automatically, it has to happen manually by going into the editor, Ctrl+A + backspace and then dragging the script into the editor (dragging into the asset browser doesn’t work, the new script isn’t recognized, and instead the project is launched with old scripts)

Apart from the flawed scripting workflow, Playcanvas is excellent though :slight_smile:

To add a bit to my post, I think a required feature would be to allow updating of scripts via the REST API, this would basically fix most of the problems when editing scripts locally.

I would then create a VSCode task which runs the Typescript compiler, and then uploads the script to PlayCanvas. It’s not perfect because different team members might overwrite each others changes, but better than what’s available now (so the next thing that’s needed would be some sort of ‘locking feature’).

@Andre_Weissflog, you should check out @whydoidoit’s work on this using the unofficial editor API here: TEMPLATE: ES6 | Version Control | NPM | PlayCanvas

1 Like

Aha looks there’s already a hidden POST call in the REST API to upload script files: https://github.com/whydoidoit/playcanvas-webpack-plugin/blob/5a3f5c8981aeca4b0a474f49d01789550922158b/index.js#L36

Thanks for the hint, this looks like what I need :slight_smile:

Bear in mind that it is a private API and therefore subject to change/removal. :wink:

Will do, it’s only for internal workflows, so if it breaks its not a big deal. It would be nice if this area (of connecting local tools to the web editor) wouldn’t be forgotten in the future though :slight_smile:

I think the cloud-based / collaborative approach works extremely well for bringing everything together (building maps, tweaking attributes, etc…), it’s almost like magic. But for coding or importing assets it would be nice to have direct connections to local tools.

For instance:

  • a PlayCanvas VSCode extension which directly hooks into the script editing workflow (and maybe even allows debugging inside VSCode), most important here is free choice of tools and ability to use our own version control systems.
  • less important but nice to have: plugins for Maya/Max/Blender to directly export to the PlayCanvas editor (for instance Maya has “Send to Unity” and “Send to Unreal” menu items)

Cheers,
-Floh.

1 Like

Ok, got it working, thanks for the help :slight_smile:

One bug(?) I noticed is:

When dragging a script file into the asset browser, or by uploading via the private POST call, the text editor doesn’t show the new version no matter what (refresh in text editor or scene editor doesn’t help).

When downloading the script, or launching the game, the new version is used though.

Known issue, or should I put this somewhere on a bug tracker?

When I change or create a new script I have to select it and click “Parse” or, if it’s attached to an entity, I select the entity and click a small icon to parse it. Otherwise, I don’t see the new attributes.
I think it’s like this by design. But for sure would be nice some more automation.