However, if you are using Unity API calls then you would end up having to re-write the bits that call Unity code. It might work if you have a very general library that doesn’t depend on anything from Unity.
It’s also worth pointing out that there are certain parts of the Unity API that are very similar to the PlayCanvas API. For example, the functions for moving/rotating/scaling entities or the physics API. It’s pretty easy to translate your Unity scripts that use these kinds of functions. And Unity and PlayCanvas scripts do share a similar structure. There’s an initialization (wake) function and an update function. So structurally, there’s not much difference between your scripts whether they’re in Unity or PlayCanvas.