Class ShapeGenerator
Functions for creating ProBuilderMesh primitives.
Inheritance
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. |
| System.Single | angle | Amount of a circle the arch takes up. |
| System.Single | radius | Distance from origin to furthest extent of geometry. |
| System.Single | width | Distance from arch top to inner radius. |
| System.Single | depth | Depth of arch blocks. |
| System.Int32 | radialCuts | How many blocks compose the arch. |
| System.Boolean | insideFaces | Render inside faces toggle. |
| System.Boolean | outsideFaces | Render outside faces toggle. |
| System.Boolean | frontFaces | Render front faces toggle. |
| System.Boolean | backFaces | Render back faces toggle. |
| System.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. |
| System.Single | radius | Radius of the generated cone. |
| System.Single | height | How tall the cone will be. |
| System.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. |
| System.Single | stairWidth | The width of the stair set. |
| System.Single | height | The height of the stair set. |
| System.Single | innerRadius | The radius from center to inner stair bounds. |
| System.Single | circumference | The amount of curvature in degrees. |
| System.Int32 | steps | How many steps this stair set contains. |
| System.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. |
| System.Int32 | axisDivisions | How many divisions to create on the vertical axis. Larger values = smoother surface. |
| System.Single | radius | The radius in world units. |
| System.Single | height | The height of this object in world units. |
| System.Int32 | heightCuts | The amount of divisions to create on the horizontal axis. |
| System.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. |
| System.Single | totalWidth | The total width of the door |
| System.Single | totalHeight | The total height of the door |
| System.Single | ledgeHeight | The height between the top of the door frame and top of the object |
| System.Single | legWidth | The width of each leg on both sides of the door |
| System.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. |
| System.Single | radius | The radius of the sphere. |
| System.Int32 | subdivisions | How many subdivisions to perform. |
| System.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. |
| System.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. |
| System.Single | radius | Radius of the generated pipe. |
| System.Single | height | Height of the generated pipe. |
| System.Single | thickness | How thick the walls will be. |
| System.Int32 | subdivAxis | How many subdivisions on the axis. |
| System.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. |
| System.Single | width | Plane width. |
| System.Single | height | Plane height. |
| System.Int32 | widthCuts | Divisions on the X axis. |
| System.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. |
| System.Int32 | steps | How many steps does the stairset have. |
| System.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. |
| System.Int32 | rows | The number of horizontal divisions. |
| System.Int32 | columns | The number of vertical divisions. |
| System.Single | innerRadius | The distance from center to the inner bound of geometry. |
| System.Single | outerRadius | The distance from center to the outer bound of geometry. |
| System.Boolean | smooth | True marks all faces as one smoothing group, false does not. |
| System.Single | horizontalCircumference | The circumference of the horizontal in degrees. |
| System.Single | verticalCircumference | The circumference of the vertical geometry in degrees. |
| System.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. |