Documentation

Unity Engine

Download Unity

Unity Engine

DrawMeshNow

Draw a mesh immediately.
Read time 4 minutesLast updated 2 days ago

Definition

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

DrawMeshNow(Mesh, Vector3, Quaternion, int)

Draw a mesh immediately.
public static void DrawMeshNow(Mesh mesh, Vector3 position, Quaternion rotation, int materialIndex)

Parameters

mesh

The Mesh to draw.

position

Position of the mesh.

rotation

Rotation of the mesh.

materialIndex

Subset of the mesh to draw.

Remarks

This function will draw a given mesh immediately. Currently set shader and material (see Material.SetPass) will be used.
The mesh will be just drawn once, it won't be per-pixel lit and will not cast or receive real-time shadows. If you want full integration with lighting and shadowing, use Graphics.DrawMesh instead.
using UnityEngine;using System.Collections;// Attach this script to any GameObject in the scene.public class ExampleClass : MonoBehaviour { public Mesh mesh; // Use a material with an unlit shader, such as Universal Render Pipeline/Unlit. // Lit shaders need lighting data that Unity sets up only for objects the render pipeline draws. public Material mat; // Unity calls this after each camera renders the scene. public void OnRenderObject() { // set first shader pass of the material mat.SetPass(0); // draw mesh at the origin Graphics.DrawMeshNow(mesh, Vector3.zero, Quaternion.identity); }}
Additional Resources: Graphics.DrawMesh, Material.SetPass.

DrawMeshNow(Mesh, Matrix4x4, int)

Draw a mesh immediately.
public static void DrawMeshNow(Mesh mesh, Matrix4x4 matrix, int materialIndex)

Parameters

mesh

The Mesh to draw.

matrix

The transformation matrix of the mesh (combines position, rotation and other transformations).

materialIndex

Subset of the mesh to draw.

Remarks

This function will draw a given mesh immediately. Currently set shader and material (see Material.SetPass) will be used.
The mesh will be just drawn once, it won't be per-pixel lit and will not cast or receive real-time shadows. If you want full integration with lighting and shadowing, use Graphics.DrawMesh instead.
using UnityEngine;using System.Collections;// Attach this script to any GameObject in the scene.public class ExampleClass : MonoBehaviour { public Mesh mesh; // Use a material with an unlit shader, such as Universal Render Pipeline/Unlit. // Lit shaders need lighting data that Unity sets up only for objects the render pipeline draws. public Material mat; // Unity calls this after each camera renders the scene. public void OnRenderObject() { // set first shader pass of the material mat.SetPass(0); // draw mesh at the origin Graphics.DrawMeshNow(mesh, Vector3.zero, Quaternion.identity); }}
Additional Resources: Graphics.DrawMesh, Material.SetPass.

DrawMeshNow(Mesh, Vector3, Quaternion)

Draw a mesh immediately.
public static void DrawMeshNow(Mesh mesh, Vector3 position, Quaternion rotation)

Parameters

mesh

The Mesh to draw.

position

Position of the mesh.

rotation

Rotation of the mesh.

Remarks

This function will draw a given mesh immediately. Currently set shader and material (see Material.SetPass) will be used.
The mesh will be just drawn once, it won't be per-pixel lit and will not cast or receive real-time shadows. If you want full integration with lighting and shadowing, use Graphics.DrawMesh instead.
using UnityEngine;using System.Collections;// Attach this script to any GameObject in the scene.public class ExampleClass : MonoBehaviour { public Mesh mesh; // Use a material with an unlit shader, such as Universal Render Pipeline/Unlit. // Lit shaders need lighting data that Unity sets up only for objects the render pipeline draws. public Material mat; // Unity calls this after each camera renders the scene. public void OnRenderObject() { // set first shader pass of the material mat.SetPass(0); // draw mesh at the origin Graphics.DrawMeshNow(mesh, Vector3.zero, Quaternion.identity); }}
Additional Resources: Graphics.DrawMesh, Material.SetPass.

DrawMeshNow(Mesh, Matrix4x4)

Draw a mesh immediately.
public static void DrawMeshNow(Mesh mesh, Matrix4x4 matrix)

Parameters

mesh

The Mesh to draw.

matrix

The transformation matrix of the mesh (combines position, rotation and other transformations).

Remarks

This function will draw a given mesh immediately. Currently set shader and material (see Material.SetPass) will be used.
The mesh will be just drawn once, it won't be per-pixel lit and will not cast or receive real-time shadows. If you want full integration with lighting and shadowing, use Graphics.DrawMesh instead.
using UnityEngine;using System.Collections;// Attach this script to any GameObject in the scene.public class ExampleClass : MonoBehaviour { public Mesh mesh; // Use a material with an unlit shader, such as Universal Render Pipeline/Unlit. // Lit shaders need lighting data that Unity sets up only for objects the render pipeline draws. public Material mat; // Unity calls this after each camera renders the scene. public void OnRenderObject() { // set first shader pass of the material mat.SetPass(0); // draw mesh at the origin Graphics.DrawMeshNow(mesh, Vector3.zero, Quaternion.identity); }}
Additional Resources: Graphics.DrawMesh, Material.SetPass.