Search Unity

Can't build when I'm using functions from UnityEditor.ProBuilder in the code

Discussion in 'Package Manager' started by LoneSurvivor82, Oct 10, 2020.

  1. LoneSurvivor82

    LoneSurvivor82

    Joined:
    Aug 17, 2019
    Posts:
    42
    Hello everyone,

    I am using some methods from the UnityEditor.ProBuilder-Assembly in my code, namely

    Optimize and RebuildColliders because I am doing some mesh-manipulation on runtime:

    Code (CSharp):
    1. using UnityEditor.ProBuilder;
    2. ...
    3.  
    4. public void Awake()
    5.     {
    6.         pb = GetComponent<ProBuilderMesh>();
    7.     }
    and later on:

    Code (CSharp):
    1.  
    2. protected void FinishMesh()
    3.     {
    4.         pb.ToMesh();
    5.         pb.Refresh();
    6.         pb.Optimize();
    7.  
    8.         pb.RebuildColliders();
    9.         Collider collider = GetComponent<Collider>();
    10.         collider.enabled = false;
    11.         collider.enabled = true;
    12.     }
    13.  
    This works when I am in editor-mode, so the game compiles and I can start it.

    But if I try to build the game, it fails with the following error:

    error CS0234: The type or namespace name 'ProBuilder' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)

    Is there any hint you can give to build it successfully?

    Thank you very much
    Ricky