Transparent Background (Programmatically)

Dear all,

We’re currently working with PlayCanvas version 1.65.5 and have encountered a challenge regarding canvas transparency.

When we set contextOptions.alpha to true programmatically (prior to loading the package) and adjust camera.clearColor using new this.pc.Color(0, 0, 0, 0), the canvas background does not appear transparent. Interestingly, this behavior differs from when we enable the “Transparent Canvas” option before exporting the package directly from the editor.

To understand this disparity, we examined the four related JSON files (config.json and {package}.json). Our analysis primarily indicated variations around these two parameters. This led us to believe that the “Transparent Canvas” setting might involve additional configurations beyond just setting the alpha value to true.

Could you kindly guide us on how to achieve a transparent background (or switch it back to opaque) for an exported package using code?

Thank you for your assistance!

Solved!