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.
Consider this scenario where
Derivedis a subclass ofBase(in TypeScript):When now this line is executed the wrong name is taken:
engine/src/script/script.js
Line 138 in 3864976
Since
Derivedis aBaseandBase.__namewas set to "Base" before,Derived.__namereturns "Base" as well.When a few lines later the
Derivedscript is registered, it replaces the already registeredBasescript and calls theswapmethod.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.