Search Unity

Having Trouble compiling code using the ProBuilder API.

Discussion in 'World Building' started by UpstreamAd, Mar 25, 2019.

  1. UpstreamAd

    UpstreamAd

    Joined:
    Jan 11, 2019
    Posts:
    10
    Hi!

    This is probably going to turn out to be an embarassing question, but I have recently upgraded (from pre-3.0) to ProBuilder 4.0.4. and am having trouble getting my code to compile using the new API.

    I'm itching to refactor my Probuilder script work to the new API, but for some reason I'm unable to compile any code that relates to it.

    For simplicity, I created a new empty project, installed the 4.0.4 package from the package manager, created a new probuild cube in an empty scene and attached the following script:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.ProBuilder;

    public class ProBuildMeshTest : MonoBehaviour
    {
    ProBuilderMesh pbm = null;
    }


    However, It's not compiling:

    Assets\ProBuildMeshTest.cs(8,5): error CS0246: The type or namespace name 'ProBuilderMesh' could not be found (are you missing a using directive or an assembly reference?)

    Here's my unity editor for ref:

    upload_2019-3-25_19-57-39.png

    Am I simply misunderstanding what I need to do to begin using this? Have I forgotten a step?

    Any help would be really appreciated. Thanks, all!

    Adam.
     
  2. UpstreamAd

    UpstreamAd

    Joined:
    Jan 11, 2019
    Posts:
    10
    Hi everyone. For posterity, it looks like I should have been up to speed with the Script compilation and assembly definition files. It seems that if I create one of these near the code using the Probuild definitions, it works!

    This thread has details of someone else overcoming the same issue:

    Hope this helps anyone else. @gabrielw_unity I'm pinging this for your interest. I had a good skim over the documents about the API, but didn't come across this solution, perhaps it's worth adding?