Attention

You are viewing PyUnity docs under the develop branch. As such, they are only applicable if you installed from source. Go to https://docs.pyunity.x10.bz/en/latest/ for the most recent release.

# pyunity.meshes module¶

Module for meshes created at runtime and their various attributes.

class pyunity.meshes.Mesh[source]

Bases:

Class to create a mesh for rendering with a MeshRenderer

Parameters
• verts () – List of Vector3’s containing each vertex

• triangles () – List of ints containing triangles joining up the vertices. Each int is the index of a vertex above.

• normals () – List of Vector3’s containing the normal of each vertex.

verts

List of Vector3’s containing each vertex

Type

triangles

List of lists containing triangles joining up the vertices. Each int is the index of a vertex above. The list is two-dimesional, meaning that each item in the list is a list of three ints.

Type

normals

List of Vector3’s containing the normal of each vertex.

Type

texcoords

List of lists containing the texture coordinate of each vertex. The list is two-dimesional, meaning that each item in the list is a list of two floats.

Type

(optional)

Notes

When any of the mesh attributes are updated while a scene is running, you must use compile(force=True) to update the mesh so that it is displayed correctly.

>>> mesh = Mesh.cube(2)
>>> mesh.vertices[1] = Vector3(2, 0, 0)
>>> mesh.compile(force=True)

compile(force=False)[source]
draw()[source]
copy()[source]

Create a copy of the current Mesh.

Returns

Copy of the mesh

Return type

GetAssetFile(gameObject)[source]
SaveAsset(ctx)[source]

Parameters

size () – Side length of quad

Returns

A quad centered at Vector3(0, 0) with side length of size facing in the direction of the negative z axis.

Return type

Parameters

size () – Side length of quad

Returns

A double-sided quad centered at Vector3(0, 0) with side length of size.

Return type

static cube(size)[source]

Creates a cube mesh.

Parameters

size () – Side length of cube

Returns

A cube centered at Vector3(0, 0, 0) that has a side length of size

Return type

class pyunity.meshes.Material[source]

Bases:

Class to hold data on a material.

color

An albedo tint.

Type

texture

A texture to map onto the mesh provided by a MeshRenderer

Type

GetAssetFile(gameObject)[source]
SaveAsset(ctx)[source]
class pyunity.meshes.Color[source]

Bases:

toString()[source]
static fromString(string)[source]
class pyunity.meshes.RGB[source]

Bases:

A class to represent an RGB color.

Parameters
• r () – Red value (0-255)

• g () – Green value (0-255)

• b () – Blue value (0-255)

toRGB()[source]
toHSV()[source]
static fromHSV(h, s, v)[source]
class pyunity.meshes.HSV[source]

Bases:

A class to represent a HSV color.

Parameters
• h () – Hue (0-360)

• s () – Saturation (0-100)

• v () – Value (0-100)

toRGB()[source]
toHSV()[source]
static fromRGB(r, g, b)[source]
class pyunity.meshes.MeshRenderer[source]

Component to render a mesh at the position of a transform.

mesh = None

Mesh that the MeshRenderer will render.

Type

mat = <pyunity.meshes.Material object at 0x7fa605526dc0>

Material to use for the mesh

Type

DefaultMaterial = <pyunity.meshes.Material object>

Type:

Render()[source]

Render the mesh that the MeshRenderer has.