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
Position of the mesh.
Rotation of the mesh.
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
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
Position of the mesh.
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
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.