Skip to content

Subclass of a script replaces the superclass script #2881

Description

@detzt

Consider this scenario where Derived is a subclass of Base (in TypeScript):

class Base extends pc.ScriptType { ... }
pc.registerScript(Base);

class Derived extends Base { ... }
pc.registerScript(Derived);

When now this line is executed the wrong name is taken:

name = name || script.__name || ScriptType.__getScriptName(script);

Since Derived is a Base and Base.__name was set to "Base" before, Derived.__name returns "Base" as well.
When a few lines later the Derived script is registered, it replaces the already registered Base script and calls the swap method.

Additional info:
Everything works as intended if I supply an explicit name like pc.registerScript(Derived, "Derived"); , so the issue is mainly about finding the correct name of the script class to register.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions