Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Pro Builder - boolean removed?

Discussion in 'World Building' started by N1warhead, Dec 27, 2019.

  1. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Are the boolean tools on Pro Builder removed? I can't seem to find them anymore.
     
    hopetolive likes this.
  2. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,662
  3. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
  4. Blueprinter

    Blueprinter

    Joined:
    Nov 28, 2019
    Posts:
    10
    Do we have any updates on this? I started using ProBuilder and was wondering how to set a mesh to subtraction mode. I saw a YouTube video talking about this Boolean feature, but I can't find it in Unity 2019.3.
     
  5. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    They are still present, but you have to first enable "Experimental Features" in the ProBuilder preferences.
     
  6. qq294716498

    qq294716498

    Joined:
    Jun 20, 2017
    Posts:
    4
    I want to call the boolean API at runtime
     
  7. Blueprinter

    Blueprinter

    Joined:
    Nov 28, 2019
    Posts:
    10
    Thanks! I didn't know Packages could have their own options in the Preferences windows. Now I'm able to access that feature, but I'm getting a StackOverflowException when I try to subtract a cylinder from a cube.

    Code (csharp):
    1.  
    2. StackOverflowException: The requested operation caused a stack overflow.
    3. System.Collections.Generic.List`1[T].set_Capacity (System.Int32 value) (at <437ba245d8404784b9fbab9b439ac908>:0)
    4. System.Collections.Generic.List`1[T].EnsureCapacity (System.Int32 min) (at <437ba245d8404784b9fbab9b439ac908>:0)
    5. System.Collections.Generic.List`1[T].Add (T item) (at <437ba245d8404784b9fbab9b439ac908>:0)
    6. UnityEngine.ProBuilder.Experimental.CSG.CSG_Plane.SplitPolygon (UnityEngine.ProBuilder.Experimental.CSG.CSG_Polygon polygon, System.Collections.Generic.List`1[T] coplanarFront, System.Collections.Generic.List`1[T] coplanarBack, System.Collections.Generic.List`1[T] front, System.Collections.Generic.List`1[T] back) (at Library/PackageCache/com.unity.probuilder@4.2.1/Runtime/MeshOperations/CSG/Classes/CSG_Plane.cs:89)
    7. UnityEngine.ProBuilder.Experimental.CSG.CSG_Node.Build (System.Collections.Generic.List`1[T] list) (at Library/PackageCache/com.unity.probuilder@4.2.1/Runtime/MeshOperations/CSG/Classes/CSG_Node.cs:112)
    8. UnityEngine.ProBuilder.Experimental.CSG.CSG_Node.Build (System.Collections.Generic.List`1[T] list) (at Library/PackageCache/com.unity.probuilder@4.2.1/Runtime/MeshOperations/CSG/Classes/CSG_Node.cs:128)
    9. (Repeats last line forever)
    10.  
    I won't be using this anymore since I've found a different solution for what I needed to do, but hopefully you can take care of this error in the near future.
     
    hopetolive, BrainSlugs83 and JBacal like this.
  8. MlleBun

    MlleBun

    Joined:
    Sep 19, 2017
    Posts:
    163
    Blueprinter likes this.
  9. Santiago-Morales

    Santiago-Morales

    Joined:
    Oct 23, 2019
    Posts:
    1
    In case someone was wondering how to enable it go to Edit > Preferences and it's under ProBuilder
     
  10. MilenaRocha

    MilenaRocha

    Joined:
    Jun 30, 2018
    Posts:
    12
    Anyway I can access to the boolean (CSG) features runtime (API)?
     
  11. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    The ProBuilder interface to these functions is private, but you could simply use the CSG library directly. See https://github.com/karl-/pb_CSG.

    On the ProBuilder side, all we're doing is calling into that library and then re-ProBuilderizing the results. Ex,

    Code (CSharp):
    1.             UnityEngine.ProBuilder.Csg.Model result;
    2.  
    3.             switch (operation)
    4.             {
    5.                 case BooleanOperation.Union:
    6.                     result = CSG.Union(lhs.gameObject, rhs.gameObject);
    7.                     break;
    8.  
    9.                 case BooleanOperation.Subtract:
    10.                     result = CSG.Subtract(lhs.gameObject, rhs.gameObject);
    11.                     break;
    12.  
    13.                 default:
    14.                     result = CSG.Intersect(lhs.gameObject, rhs.gameObject);
    15.                     break;
    16.             }
    17.  
    18.             var materials = result.materials.ToArray();
    19.             ProBuilderMesh pb = ProBuilderMesh.Create();
    20.             pb.GetComponent<MeshFilter>().sharedMesh = (Mesh) result;
    21.             pb.GetComponent<MeshRenderer>().sharedMaterials = materials;
    22.             MeshImporter importer = new MeshImporter(pb.gameObject);
    23.             importer.Import(new MeshImportSettings() { quads = true, smoothing = true, smoothingAngle = 1f });
    24.             pb.Rebuild();
    25.             pb.CenterPivot(null);
    26.             Selection.objects = new Object[] { pb.gameObject };
     
    MilenaRocha likes this.
  12. nauroman

    nauroman

    Joined:
    Nov 1, 2014
    Posts:
    13
    UnityEngine.ProBuilder.Csg is not acceptable. Is there a way to use CSG.Subtract or somehow get access from c# to ProBuilder boolean API in realtime?
     
  13. CarrySchli

    CarrySchli

    Joined:
    Sep 20, 2022
    Posts:
    5
    Is there a way to you use both packages at the same time? Like I get an error when I am importing the CSG package in addition to ProBuilder. (Assembly with name 'Unity.Probuilder.Csg' already exists.)

    I am of course aware why the error is triggered but is there also a workaround?
     
  14. Murkes

    Murkes

    Joined:
    Sep 2, 2021
    Posts:
    3
    I downloaded the package that @kaarrrllll mentioned and was able to use functions just like the ones provided from Probuilder at runtime as he said. https://github.com/karl-/pb_CSG the github page explains how to use the package and its super straight forward with only a few lines of code. For example you can do things like CSG.Subtract, etc.

    You might get errors if you have both the package and probuilder in your project at the same time but I'm sure there are ways to resolve those errors. I personally only needed the CSG package so I didn't have to go down that route.
     
  15. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    This is still a problem.. is there a fix ?
     
  16. factober

    factober

    Joined:
    Sep 15, 2023
    Posts:
    5
    I enabled it from preferences. But, when I tried subtracting objects, it crashed the whole Unity 2022.3.
     
  17. EvgenyKralko

    EvgenyKralko

    Joined:
    Mar 8, 2019
    Posts:
    1
    Here are the steps to fix "Assembly with name 'Unity.Probuilder.Csg' already exists" issue.
    1. Open your project solution in Visual Studio
    2. Find Unity.Probuilder.Csg project and rename it to Unity.Standalone.Csg for example upload_2024-1-9_18-57-48.png
    3. Open Prabox.CSG.asmdef file and rename Unity.Probuilder.Csg to Unity.Standalone.Csg upload_2024-1-9_18-59-18.png
    4. To fix the same issue for Parabox.CSG.Demo project - open Parabox.CSG.Demo.asmdef file and rename Unity.Probuilder.Csg to Unity.Standalone.Csg
     
    NapalmRain likes this.