ES6-style script definition not working anymore in v1.52.1

Hello!

I’ve noticed that ES6-like script definition has stopped working in 1.52.0/1.52.1.
For example:

class Something extends pc.ScriptType {

    initialize() {
         ....
    }

    update(dt) {

    }
}


pc.registerScript(Something, 'something');

Here is the test project:

https://playcanvas.com/project/881557/overview/es6-script-inheritance
And two test links (please open the console to see script’s debug output)
1.51.7 is working fine: https://launch.playcanvas.com/1333994?debug=true
1.52.1 is not working: https://launch.playcanvas.com/1333994?debug=true&version=1.52.1

Is there a way to use the ES6 classes/inheritance? I know you guys have been converting the codebase to TS/ES6 last months, right?

@will Something for you?

Looks fine here?

Edit: Oooh, there should be console output right?

It’s likely due to be because of this change: https://github.com/playcanvas/engine/pull/3946/files#diff-c2472c99970212e0982a5a8f8c11c9f700c5fd61c88888dfd3b30808573ac1a2R240-R268

We are still working through the issues on engine 1.52 regarding type script and issues like this.

Many thanks for testing and reporting this, it really does help us a lot!

1 Like

Also, there is an issue with parsing inherited scripts in the editor. This is not something special to 1.52.x, I noticed it way before.

For example, let’s define a base class named Primitive

class Primitive extends pc.ScriptType {
...

Then extend it with the Box class:

class Box extends Primitive {
...

Attaching the Primitive script to an entity works well, but it breaks once I want to attach & parse the inherited Box class:
image

Is says the base class is not defined. Though the inheritance works (or rather worked till 1.52.x: ) ) well when you launch the project. That makes impossible using the script attributes.

@Igor that one is known:

2 Likes