Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


DrawMesh

Draws a mesh gizmo at the specified transform.
Read time 2 minutesLast updated 13 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

DrawMesh(Mesh, int, Vector3, Quaternion, Vector3)

Draws a mesh gizmo at the specified transform.
public static void DrawMesh(Mesh mesh, int submeshIndex, Vector3 position, Quaternion rotation, Vector3 scale)

Parameters

mesh

The Mesh to draw as a gizmo. Mesh objects can be created and managed, or retrieved through the MeshFilter component.

submeshIndex

The submesh to draw. The default is -1, which draws the whole mesh.

position

The mesh position in world space. The default position is zero.

rotation

The mesh orientation in world space. The default is identity quaternion.

scale

Mesh scale in world space (default is scale of 1).

Remarks

The mesh gizmo is drawn with the currently set Gizmos.color. Additional Resources: Gizmos.DrawWireMesh.

Examples

using UnityEngine;public class ExampleClass : MonoBehaviour{ Mesh mesh = null; void OnDrawGizmosSelected() { // Draws a yellow Cube at the position of the object rotated by 45 degrees around the Y axis. if (mesh is null) mesh = Resources.GetBuiltinResource<Mesh>("Cube.fbx"); Gizmos.color = Color.yellow; Gizmos.DrawMesh(mesh, transform.position, Quaternion.Euler(0f, 45f, 0f)); }}

DrawMesh(Mesh, Vector3, Quaternion, Vector3)

Draws a mesh gizmo at the specified transform.
public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation, Vector3 scale)

Parameters

mesh

The Mesh to draw as a gizmo. Mesh objects can be created and managed, or retrieved through the MeshFilter component.

position

The mesh position in world space. The default position is zero.

rotation

The mesh orientation in world space. The default is identity quaternion.

scale

Mesh scale in world space (default is scale of 1).

Remarks

The mesh gizmo is drawn with the currently set Gizmos.color. Additional Resources: Gizmos.DrawWireMesh.

Examples

using UnityEngine;public class ExampleClass : MonoBehaviour{ Mesh mesh = null; void OnDrawGizmosSelected() { // Draws a yellow Cube at the position of the object rotated by 45 degrees around the Y axis. if (mesh is null) mesh = Resources.GetBuiltinResource<Mesh>("Cube.fbx"); Gizmos.color = Color.yellow; Gizmos.DrawMesh(mesh, transform.position, Quaternion.Euler(0f, 45f, 0f)); }}