engine icon indicating copy to clipboard operation
engine copied to clipboard

resolveDuplicatedEntityReferenceProperties is not a function

Open willeastcott opened this issue 8 years ago • 4 comments

Description

The Flying Toasters scene no longer runs. The following error message is displayed in the JS console:

Uncaught TypeError: newEntity.script.resolveDuplicatedEntityReferenceProperties is not a function
    at resolveDuplicatedEntityReferenceProperties (playcanvas-stable.dbg.js:36191)
    at Entity.clone (playcanvas-stable.dbg.js:36146)
    at Spawner.spawn (spawner.js:11)
    at Spawner.initialize (spawner.js:17)
    at ScriptLegacyComponentSystem._callInstancesMethod (playcanvas-stable.dbg.js:26399)
    at ScriptLegacyComponentSystem._initializeScriptComponent (playcanvas-stable.dbg.js:26404)
    at ScriptLegacyComponentSystem.onInitialize (playcanvas-stable.dbg.js:26370)
    at ScriptLegacyComponentSystem.onInitialize (playcanvas-stable.dbg.js:26376)
    at ScriptLegacyComponentSystem.onInitialize (playcanvas-stable.dbg.js:26376)
    at Function.fire (playcanvas-stable.dbg.js:807)

Steps to Reproduce

  1. Run this scene: https://playcanvas.com/editor/scene/330459
  2. Check JS console.
  3. You should see:

image

willeastcott avatar Sep 19 '18 20:09 willeastcott

This function is part of ScriptComponent, so tried to figure out why it is 'newEntity.script' rather then newEntity.c.script? Could it be the actual issue? If not where this newEntity.script is being created?

e-strokov avatar Sep 20 '18 13:09 e-strokov

No. The problem is because we have a legacy script component which is preserved to support older projects:

https://github.com/playcanvas/engine/tree/master/src/framework/components/script-legacy

We select which script component to use here:

https://github.com/playcanvas/engine/blob/master/src/framework/application.js#L473

So the problem is because resolveDuplicatedEntityReferenceProperties is defined for the current script component, but when it was added, attention was not given to the legacy script component.

We didn't have entity attributes when the legacy script component was the default, so I'm not entirely sure what the right thing to do is. @daredevildave?

willeastcott avatar Sep 20 '18 14:09 willeastcott

Probably just need to add a check for pc.script.legacy before calling this behaviour

daredevildave avatar Sep 20 '18 18:09 daredevildave

Sounds like a good solution. Done.

willeastcott avatar Sep 20 '18 20:09 willeastcott