Class ShapeGenerator
Provides functions for creating ProBuilderMesh primitives.
Inherited Members
Namespace: UnityEngine.ProBuilder
Assembly: Unity.ProBuilder.dll
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, float, float, float, float, int, bool, bool, bool, bool, bool)
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). |
float | angle | Set the portion of a circle the arch takes up as an angle. |
float | radius | Set the distance from the origin to the furthest extent of the bounding box. |
float | width | Set the distance from the top of the arch to the inner radius. |
float | depth | Set the depth of the arch blocks. |
int | radialCuts | Set the number of blocks in the arch. |
bool | insideFaces | Set whether to render the inside faces. |
bool | outsideFaces | Set whether to render the outside faces. |
bool | frontFaces | Set whether to render the front faces. |
bool | backFaces | Set whether to render the back faces. |
bool | 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, float, float, int)
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). |
float | radius | Set the radius of the generated cone. |
float | height | Set the height of the cone. |
int | 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, float, float, float, float, int, bool)
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). |
float | stairWidth | Set the width of the stairs. |
float | height | Set the height of the stairs. |
float | innerRadius | Set the radius from the center of the bounding box to the inner stair bounds. |
float | circumference | Set the amount of curvature in degrees. |
int | steps | Set the number of steps to build. |
bool | 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, int, float, float, int, int)
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). |
int | axisDivisions | Set the number of divisions to create on the vertical axis. The larger the value, the smoother the surface. |
float | radius | Set the radius in world units. |
float | height | Set the height of this object in world units. |
int | heightCuts | Set the amount of divisions to create on the horizontal axis. |
int | smoothing | Set the smoothing group ID (index). |
Returns
Type | Description |
---|---|
ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateDoor(PivotLocation, float, float, float, float, float)
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). |
float | totalWidth | Set the total width of the door. |
float | totalHeight | Set the total height of the door. |
float | ledgeHeight | Set the height between the top of the door frame and the top of the object. |
float | legWidth | Set the width of each leg on both sides of the door. |
float | 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, float, int, bool, bool)
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). |
float | radius | Set the radius of the sphere. |
int | subdivisions | Set the number of subdivisions to perform. |
bool | 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. |
bool | 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, float, float, float, int, int)
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). |
float | radius | Set the radius of the pipe. |
float | height | Set the height of the pipe. |
float | thickness | Set the thickness of the walls. |
int | subdivAxis | Set the number of subdivisions on the axis. |
int | 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, float, float, int, int, 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). |
float | width | Set the width of the plane. |
float | height | Set the height of the plane. |
int | widthCuts | Set the divisions on the X-axis. |
int | 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, int, bool)
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. |
int | steps | Set the number of steps to build. |
bool | 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, int, int, float, float, bool, float, float, bool)
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). |
int | rows | Set the number of horizontal divisions to create. |
int | columns | Set the number of vertical divisions to create. |
float | innerRadius | Set the distance from the center to the inner bounds of this shape. |
float | outerRadius | Set the distance from the center to the outer bounds of this shape. |
bool | smooth | Set to true to mark all faces as one smoothing group; false for no smoothing groups. |
float | horizontalCircumference | Set the horizontal circumference in degrees. |
float | verticalCircumference | Set the vertical circumference in degrees. |
bool | 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. |