Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Help with ProBuilder "Class CombineMeshes"

Discussion in 'World Building' started by nobluff67, Mar 22, 2020.

  1. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    151
  2. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    151
    Ok, think I figured this out through brute force and luck.

    Code (CSharp):
    1. List<ProBuilderMesh> meshesToCombine = new List<ProBuilderMesh>();
    2. ProBuilderMesh combineToMesh = new ProBuilderMesh(); // add probuilder mesh component to gameobject.
    3. .
    4. .
    5. .
    6. meshesToCombine.Add(GetComponent<ProBuilderMesh>()); // remove probuilder mesh afterwards if you want.
    7. .
    8. .
    9. CombineMeshes.Combine(meshesToCombine, combineToMesh);
     
  3. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    151
    Back again, maybe I don't quite understand the concept! I am actually trying to combine probuilder objects via code. I thought this is what the mesh combine was supposed to do.

    I have combined the meshes of gameobjects a,b,c into gameobject d. I was under the impression that the combined mesh in d will show the entire object when I deactivate a,b,c, however this is not happening. Everything disappears.

    Am I misunderstanding something?
     
  4. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    258
  5. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    151
    Thanks you so much, that helped alot.

    For anyone else Ignore my original code as there is a mistake in there. Just follow the example in the quoted post above.

    FYI, my main mistake was this line:
    CombineMeshes.Combine(meshesToCombine, combineToMesh);

    which should be:

    List<ProBuilderMesh> res = CombineMeshes.Combine(meshesToCombine, combineToMesh);
     
unityunity