I create a box at runtime with probuilder, when built on WebGL and opened on browser I get runtime error “AddComponent asking for “BoxCollider” which is not a Unity engine type.” and no OnMouseDown is registered, so can’t interact with 3D object. It works just fine on editor.
Tested on probulider 4.2.1 and 4.3.0 prev .1 , Unity 2019.3.0f3, URP 7.1.6
Anyone having this problem and found a solution? Bug raised here.
Thanks a bunch for your help
In case it helps anyone with this prob, here’s the reponse Unity team kindly sent over and solved the issue in my case cos I had a mesh only when built at runtime:
The project has Engine code stripping enabled, which removes unused Engine code from the build. In your case, none of the scenes are using the “BoxCollider” component, so it gets stripped from the build during the code stripping phase, and thus later you encounter those errors. To fix this behavior, you can either disable code stripping in the Player Settings or create some “dummy” object which would store the needed components and prevent them from being stripped.
In order to fix this create an empty game object and add the component that you need onto it. Then drag this into the Resources folder to create the dummy prefab.
@Tarrag thank you so much for sharing this! Disabling code stripping or using prefab references instead of generating Objects in code solved the problem for me.