Find a way to convert Unity Project to PlayCanvas project

I come across PlayCanvas these days and I’m new here. I want to use it to make some playable ads form existing Unity projects. I found that PlayCanvas can export/import projects. So I have a thought to write a automatic tool to convert unity hierarchy(without scripts) to the PlayCanvas project which will be very helpful for some complex scenes.

I found the hash values in hases.json are special, I can’t generate them by any knowing algorithms, so I can’t generate a custom project offline and import it.

Is there a official way to do this?

Hi @LoveDB and welcome,

No there isn’t an official way in doing so. But you can use the editor API to do that.

I imagine one way would be to export the Unity scene hierarchy to a JSON format, then parse that in the PlayCanvas editor and create the required entities and components using the editor API.

The assets can be easily mass imported, and you can use naming conventions to pinpoint any component asset reference required.

https://developer.playcanvas.com/en/user-manual/designer/editor-api/

Thanks very much. I’ll try the editor API asap.

Here I have two more questions about the corrdinate system and the values during conversion:

  1. Unity use left-handed corrdinate system, but PlayCanvas use right-handed system. Is it a right way to simply change the sign of Z of all position values?
  2. I create a simple plane in Unity and import a tree FBX. I also do the same thing in the PlayCanvas. But I have to change many values to get the similar display.

It seems that all FBXs are 100 times bigger and the basic geometry(Plane) is 10 times smaller. Also I have to convert the camera’s position and light’s rotation based on the coordinate difference.

I’m not sure whether I’m on the right way to do the conversion. Any other concerns?

Should be yes as negative Z is forward in PlayCanvas’ case. Rotation direction may also be affected on some axes.

I haven’t used Unity for a little while. I think there is a per asset option to scale the model? In PlayCanvas, use what is set to be 1m in the FBX to be 1 unit in the PlayCanvas IIRC which may explain the 100x difference. You could scale the template root to be 100x less and apply it back to the template asset.

Primitives scale may be different to the presets in Unity. We generally have them set to be 1 unit.