Search Unity

Probuilder on WebGL Add BoxCollider - WebGL error "BoxCollider not Unity engine type"-can't interact

Discussion in 'World Building' started by Tarrag, Jan 12, 2020.

  1. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    215
    Hey all,

    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
     
    Max-Modestov and D12294 like this.
  2. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    215
    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.
     
  3. GregBahm

    GregBahm

    Joined:
    Jul 1, 2014
    Posts:
    11
    Thank you so much for coming back and posting this! I just ran into the same issue with using GameObject.CreatePrimitive(PrimitiveType.Quad);
     
  4. TallPaulUK

    TallPaulUK

    Joined:
    Jul 27, 2013
    Posts:
    7
    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.
     
  5. D12294

    D12294

    Joined:
    Oct 6, 2020
    Posts:
    81
    @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.
     
  6. Cuttlas-U

    Cuttlas-U

    Joined:
    Apr 11, 2017
    Posts:
    38
    Thanks its fixed now