Class ShapeGenerator
Provides functions for creating ProBuilderMesh primitives.
Inherited Members
Namespace: UnityEngine.ProBuilder
Syntax
public static class ShapeGenerator
Methods
CreateShape(ShapeType, PivotLocation)
Creates a shape with default parameters.
In the Editor, the equivalent is the Shape tool.
Declaration
public static ProBuilderMesh CreateShape(ShapeType shape, PivotLocation pivotType = PivotLocation.Center)
Parameters
| Type | Name | Description |
|---|---|---|
| ShapeType | shape | The ShapeType to create. |
| PivotLocation | pivotType | Where the shape's pivot will be. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with the ProBuilderMesh initialized to the primitve shape. |
GenerateArch(PivotLocation, Single, Single, Single, Single, Int32, Boolean, Boolean, Boolean, Boolean, Boolean)
Creates a new arch shape.
Declaration
public static ProBuilderMesh GenerateArch(PivotLocation pivotType, float angle, float radius, float width, float depth, int radialCuts, bool insideFaces, bool outsideFaces, bool frontFaces, bool backFaces, bool endCaps)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Single | angle | Set the portion of a circle the arch takes up as an angle. |
| Single | radius | Set the distance from the origin to the furthest extent of the bounding box. |
| Single | width | Set the distance from the top of the arch to the inner radius. |
| Single | depth | Set the depth of the arch blocks. |
| Int32 | radialCuts | Set the number of blocks in the arch. |
| Boolean | insideFaces | Set whether to render the inside faces. |
| Boolean | outsideFaces | Set whether to render the outside faces. |
| Boolean | frontFaces | Set whether to render the front faces. |
| Boolean | backFaces | Set whether to render the back faces. |
| Boolean | endCaps | Set to true to include the faces capping the ends of this arch. This value is ignored if the radius is 360 degrees. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateCone(PivotLocation, Single, Single, Int32)
Creates a new cone shape.
Declaration
public static ProBuilderMesh GenerateCone(PivotLocation pivotType, float radius, float height, int subdivAxis)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Single | radius | Set the radius of the generated cone. |
| Single | height | Set the height of the cone. |
| Int32 | subdivAxis | Set the number of subdivisions on the axis. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateCube(PivotLocation, Vector3)
Creates a new cube with the specified size as a bounding box. The size is fixed: it is not applied as a scale value in the transform.
Declaration
public static ProBuilderMesh GenerateCube(PivotLocation pivotType, Vector3 size)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Vector3 | size | Set the position of the opposite corner of the bounding box for the cube. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateCurvedStair(PivotLocation, Single, Single, Single, Single, Int32, Boolean)
Creates a set of curved stairs.
Declaration
public static ProBuilderMesh GenerateCurvedStair(PivotLocation pivotType, float stairWidth, float height, float innerRadius, float circumference, int steps, bool buildSides)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Single | stairWidth | Set the width of the stairs. |
| Single | height | Set the height of the stairs. |
| Single | innerRadius | Set the radius from the center of the bounding box to the inner stair bounds. |
| Single | circumference | Set the amount of curvature in degrees. |
| Int32 | steps | Set the number of steps to build. |
| Boolean | buildSides | Set this to true to build the side and back walls or false to build only the stair top and connecting planes. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
See Also
GenerateCylinder(PivotLocation, Int32, Single, Single, Int32, Int32)
Creates a cylinder primitive.
Declaration
public static ProBuilderMesh GenerateCylinder(PivotLocation pivotType, int axisDivisions, float radius, float height, int heightCuts, int smoothing = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Int32 | axisDivisions | Set the number of divisions to create on the vertical axis. The larger the value, the smoother the surface. |
| Single | radius | Set the radius in world units. |
| Single | height | Set the height of this object in world units. |
| Int32 | heightCuts | Set the amount of divisions to create on the horizontal axis. |
| Int32 | smoothing | Set the smoothing group ID (index). |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateDoor(PivotLocation, Single, Single, Single, Single, Single)
Creates a door shape to place into a wall structure. Only the faces that are visible inside the walls have faces.
Declaration
public static ProBuilderMesh GenerateDoor(PivotLocation pivotType, float totalWidth, float totalHeight, float ledgeHeight, float legWidth, float depth)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Single | totalWidth | Set the total width of the door. |
| Single | totalHeight | Set the total height of the door. |
| Single | ledgeHeight | Set the height between the top of the door frame and the top of the object. |
| Single | legWidth | Set the width of each leg on both sides of the door. |
| Single | depth | Set the distance between the front and back faces of the door object. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateIcosahedron(PivotLocation, Single, Int32, Boolean, Boolean)
Creates a new icosphere shape.
Declaration
public static ProBuilderMesh GenerateIcosahedron(PivotLocation pivotType, float radius, int subdivisions, bool weldVertices = true, bool manualUvs = true)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Single | radius | Set the radius of the sphere. |
| Int32 | subdivisions | Set the number of subdivisions to perform. |
| Boolean | weldVertices | By default, this value is true, meaning that it extracts shared indexes. Set this to false to show a preview, where speed of generation is more important than making the shape editable. |
| Boolean | manualUvs | By default, this value is true, meaning that faces on icospheres are marked as manual UVs for performance reasons. Set this to false if you want ProBuilder to use auto-unwrapped UVs. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GeneratePipe(PivotLocation, Single, Single, Single, Int32, Int32)
Creates a new pipe shape.
Declaration
public static ProBuilderMesh GeneratePipe(PivotLocation pivotType, float radius, float height, float thickness, int subdivAxis, int subdivHeight)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Single | radius | Set the radius of the pipe. |
| Single | height | Set the height of the pipe. |
| Single | thickness | Set the thickness of the walls. |
| Int32 | subdivAxis | Set the number of subdivisions on the axis. |
| Int32 | subdivHeight | Set the number of subdivisions on the Y-axis. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GeneratePlane(PivotLocation, Single, Single, Int32, Int32, Axis)
Creates a new plane shape.
Declaration
public static ProBuilderMesh GeneratePlane(PivotLocation pivotType, float width, float height, int widthCuts, int heightCuts, Axis axis)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Single | width | Set the width of the plane. |
| Single | height | Set the height of the plane. |
| Int32 | widthCuts | Set the divisions on the X-axis. |
| Int32 | heightCuts | Set the divisions on the Y-axis. |
| Axis | axis | Set the axis to build the plane on. For example, |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GeneratePrism(PivotLocation, Vector3)
Creates a new prism primitive.
Declaration
public static ProBuilderMesh GeneratePrism(PivotLocation pivotType, Vector3 size)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Vector3 | size | Set the scale to apply to the shape. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateStair(PivotLocation, Vector3, Int32, Boolean)
Creates a set of straight stairs.
Declaration
public static ProBuilderMesh GenerateStair(PivotLocation pivotType, Vector3 size, int steps, bool buildSides)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Vector3 | size | Set the position of the opposite corner of the bounding box for the stairs. |
| Int32 | steps | Set the number of steps to build. |
| Boolean | buildSides | Set this to true to build the side and back walls or false to build only the stair top and connecting planes. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
See Also
GenerateTorus(PivotLocation, Int32, Int32, Single, Single, Boolean, Single, Single, Boolean)
Creates a new torus mesh.
Declaration
public static ProBuilderMesh GenerateTorus(PivotLocation pivotType, int rows, int columns, float innerRadius, float outerRadius, bool smooth, float horizontalCircumference, float verticalCircumference, bool manualUvs = false)
Parameters
| Type | Name | Description |
|---|---|---|
| PivotLocation | pivotType | Set the location of the shape's pivot (center or first corner). |
| Int32 | rows | Set the number of horizontal divisions to create. |
| Int32 | columns | Set the number of vertical divisions to create. |
| Single | innerRadius | Set the distance from the center to the inner bounds of this shape. |
| Single | outerRadius | Set the distance from the center to the outer bounds of this shape. |
| Boolean | smooth | Set to true to mark all faces as one smoothing group; false for no smoothing groups. |
| Single | horizontalCircumference | Set the horizontal circumference in degrees. |
| Single | verticalCircumference | Set the vertical circumference in degrees. |
| Boolean | manualUvs | By default, this value is false, and ProBuilder uses automatic UV wrapping for textures. To achieve better results, set this value to true to use manual UV unwrapping for textures instead. |
Returns
| Type | Description |
|---|---|
| ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |