Editor fault copying entities with asset references

Looks like it’s not possible to copy entities with asset references. The fault appears to be due to the fact that the entity ID is stored as a string but the code that is doing the copy is using “length” to see if it’s an array. Clearly strings have a length but not a “forEach” method.

The temporary workaround is to do this in the dev console:

String.prototype.forEach = function(fn) { fn.call(this, this) }
1 Like

We deployed some changes about copy pasting today which allow you to copy paste Entities between different projects. Assets referenced by the pasted Entities will be auto-matched based on the asset paths. If the paths are not found the asset references will remain missing for you to fix.

Could you tell me what components does your Entity have and you get that bug? I can fix it just curious where it happens as I haven’t been able to reproduce it.

1 Like

Not sure, something with legacy scripts and asset references! I was copying the whole of one scene into another so I had a lot selected!

That’s fantastic news on the project copy!

Well it should be fixed now let me know if you see another problem with it.

Hey I’m having another problem now pasting a single object between scenes. It initially appears in the scene, then vanishes with the following error.

This is the object being copied:

Could you select that object, and execute in console please:


It will print the JSON representation of an object, please copy-paste it here, it might have some invalid data somehow.

Do that with the one you are about to copy, and the one you have pasted. They should be almost identical, except possibly asset references and resource_id.

If I stringify the object it looks like this:

{"name":"Exterior_Light (42)","tags":[],"enabled":true,"resource_id":"3720bb9e-e25c-416a-b22c-3e30a88d7d2c","parent":"b0024a47-d3bd-4d33-bb4f-c8ce265c1a46","children":[],"position":[-55.3551636,-2.06798029,38.90971],"rotation":[270,8.050644,0],"scale":[3,3.00001335,6],"components":{"model":{"asset":"5975530","castShadows":false,"castShadowsLightmap":false,"enabled":true,"isStatic":false,"lightmapSizeMultiplier":1,"lightmapped":false,"materialAsset":null,"receiveShadows":false,"type":"asset"}}}

I can’t do the one I’ve pasted - it appears and then vanishes. Quite possibly will have some invalid data - pretty sure the original objects were created by some custom editor plugin I made :slight_smile:

Can see a problem, asset ID is not a number.

Select this entity, and paste this in console:

editor.call('selector:items')[0].set('components.model.asset', parseInt(editor.call('selector:items')[0].get('components.model.asset'), 10));

It will convert it to Integer. Shouldn’t have allowed it to be like so in first place. Would be very nice to find out how you’ve created it to be a string in first place.

Ah looks like it is an extension of the issue that Vaios fixed above. Where my imported stuff wasn’t working quite right.

Looks like calling .get(‘id’) is returning a string:

For reference this is my Unity importer editor extension.

Yes, you want to parseInt all ID’s always. As they are in mixed formats all around.

What are the features of Unity Exporter you have? :slight_smile:

Oh you can select a series of objects in Unity. Export them as a JSON file and map them onto items in PlayCanvas. So taking an entire scene and bringing it in. I’ve also modified someone else’s FBX Exporter to include AO maps and the like, export reference models etc.

I’ve written it as a Google Extension so it brings up a little UI in the corner of the editor and lets you map on the models etc. You select the file, it tries to find models with the same name, or you can specify others.


1 Like