Class ShapeGenerator
Functions for creating ProBuilderMesh primitives.
Namespace: UnityEngine.ProBuilder
Syntax
public static class ShapeGenerator
Methods
CreateShape(ShapeType, PivotLocation)
Create a shape with default parameters.
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)
Create 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 | Where the shape's pivot will be. |
Single | angle | Amount of a circle the arch takes up. |
Single | radius | Distance from origin to furthest extent of geometry. |
Single | width | Distance from arch top to inner radius. |
Single | depth | Depth of arch blocks. |
Int32 | radialCuts | How many blocks compose the arch. |
Boolean | insideFaces | Render inside faces toggle. |
Boolean | outsideFaces | Render outside faces toggle. |
Boolean | frontFaces | Render front faces toggle. |
Boolean | backFaces | Render back faces toggle. |
Boolean | endCaps | If true the faces capping the ends of this arch will be included. Does not apply if radius is 360 degrees. |
Returns
Type | Description |
---|---|
ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateCone(PivotLocation, Single, Single, Int32)
Create a new cone shape.
Declaration
public static ProBuilderMesh GenerateCone(PivotLocation pivotType, float radius, float height, int subdivAxis)
Parameters
Type | Name | Description |
---|---|---|
PivotLocation | pivotType | Where the shape's pivot will be. |
Single | radius | Radius of the generated cone. |
Single | height | How tall the cone will be. |
Int32 | subdivAxis | How many subdivisions on the axis. |
Returns
Type | Description |
---|---|
ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateCube(PivotLocation, Vector3)
Create a new cube with the specified size. Size is baked (ie, not applied as a scale value in the transform).
Declaration
public static ProBuilderMesh GenerateCube(PivotLocation pivotType, Vector3 size)
Parameters
Type | Name | Description |
---|---|---|
PivotLocation | pivotType | Where the shape's pivot will be. |
Vector3 | size | The bounds of the new cube. |
Returns
Type | Description |
---|---|
ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateCurvedStair(PivotLocation, Single, Single, Single, Single, Int32, Boolean)
Create 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 | Where the shape's pivot will be. |
Single | stairWidth | The width of the stair set. |
Single | height | The height of the stair set. |
Single | innerRadius | The radius from center to inner stair bounds. |
Single | circumference | The amount of curvature in degrees. |
Int32 | steps | How many steps this stair set contains. |
Boolean | buildSides | If true, build the side and back walls. If false, only the stair top and connecting planes will be built. |
Returns
Type | Description |
---|---|
ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateCylinder(PivotLocation, Int32, Single, Single, Int32, Int32)
Creates a cylinder pb_Object with the supplied parameters.
Declaration
public static ProBuilderMesh GenerateCylinder(PivotLocation pivotType, int axisDivisions, float radius, float height, int heightCuts, int smoothing = -1)
Parameters
Type | Name | Description |
---|---|---|
PivotLocation | pivotType | Where the shape's pivot will be. |
Int32 | axisDivisions | How many divisions to create on the vertical axis. Larger values = smoother surface. |
Single | radius | The radius in world units. |
Single | height | The height of this object in world units. |
Int32 | heightCuts | The amount of divisions to create on the horizontal axis. |
Int32 | smoothing |
Returns
Type | Description |
---|---|
ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateDoor(PivotLocation, Single, Single, Single, Single, Single)
Create a door shape suitable for placement in a wall structure.
Declaration
public static ProBuilderMesh GenerateDoor(PivotLocation pivotType, float totalWidth, float totalHeight, float ledgeHeight, float legWidth, float depth)
Parameters
Type | Name | Description |
---|---|---|
PivotLocation | pivotType | Where the shape's pivot will be. |
Single | totalWidth | The total width of the door |
Single | totalHeight | The total height of the door |
Single | ledgeHeight | The height between the top of the door frame and top of the object |
Single | legWidth | The width of each leg on both sides of the door |
Single | depth | 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)
Create 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 | Where the shape's pivot will be. |
Single | radius | The radius of the sphere. |
Int32 | subdivisions | How many subdivisions to perform. |
Boolean | weldVertices | If false this function will not extract shared indexes. This is useful when showing a preview, where speed of generation is more important than making the shape editable. |
Boolean | manualUvs | For performance reasons faces on icospheres are marked as manual UVs. Pass false to this parameter to force auto unwrapped UVs. |
Returns
Type | Description |
---|---|
ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
Remarks
This method does not build UVs, so after generating BoxProject for UVs.
GeneratePipe(PivotLocation, Single, Single, Single, Int32, Int32)
Create 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 | Where the shape's pivot will be. |
Single | radius | Radius of the generated pipe. |
Single | height | Height of the generated pipe. |
Single | thickness | How thick the walls will be. |
Int32 | subdivAxis | How many subdivisions on the axis. |
Int32 | subdivHeight | How many 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)
Create 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 | Where the shape's pivot will be. |
Single | width | Plane width. |
Single | height | Plane height. |
Int32 | widthCuts | Divisions on the X axis. |
Int32 | heightCuts | Divisions on the Y axis. |
Axis | axis | The axis to build the plane on. Ex: ProBuilder.Axis.Up is a plane with a normal of Vector3.up. |
Returns
Type | Description |
---|---|
ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GeneratePrism(PivotLocation, Vector3)
Create a new prism primitive.
Declaration
public static ProBuilderMesh GeneratePrism(PivotLocation pivotType, Vector3 size)
Parameters
Type | Name | Description |
---|---|---|
PivotLocation | pivotType | Where the shape's pivot will be. |
Vector3 | size | 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)
Create a set of stairs.
Declaration
public static ProBuilderMesh GenerateStair(PivotLocation pivotType, Vector3 size, int steps, bool buildSides)
Parameters
Type | Name | Description |
---|---|---|
PivotLocation | pivotType | Where the shape's pivot will be. |
Vector3 | size | The bounds of the stairs. |
Int32 | steps | How many steps does the stairset have. |
Boolean | buildSides | If true, build the side and back walls. If false, only the stair top and connecting planes will be built. |
Returns
Type | Description |
---|---|
ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |
GenerateTorus(PivotLocation, Int32, Int32, Single, Single, Boolean, Single, Single, Boolean)
Create a 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 | Where the shape's pivot will be. |
Int32 | rows | The number of horizontal divisions. |
Int32 | columns | The number of vertical divisions. |
Single | innerRadius | The distance from center to the inner bound of geometry. |
Single | outerRadius | The distance from center to the outer bound of geometry. |
Boolean | smooth | True marks all faces as one smoothing group, false does not. |
Single | horizontalCircumference | The circumference of the horizontal in degrees. |
Single | verticalCircumference | The circumference of the vertical geometry in degrees. |
Boolean | manualUvs | A torus shape does not unwrap textures well using automatic UVs. To disable this feature and instead use manual UVs, pass true. |
Returns
Type | Description |
---|---|
ProBuilderMesh | A new GameObject with a reference to the ProBuilderMesh component. |