Version: 2017.2
Obsolete public static void DrawMesh (Mesh mesh, Vector3 position, Quaternion rotation);
Obsolete public static void DrawMesh (Mesh mesh, Vector3 position, Quaternion rotation, int materialIndex);
public static void DrawMesh (Mesh mesh, Vector3 position, Quaternion rotation, Material material, int layer, Camera camera= null, int submeshIndex= 0, MaterialPropertyBlock properties= null, bool castShadows= true, bool receiveShadows= true, bool useLightProbes= true);
public static void DrawMesh (Mesh mesh, Vector3 position, Quaternion rotation, Material material, int layer, Camera camera, int submeshIndex, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows= true, Transform probeAnchor= null, bool useLightProbes= true);
Obsolete public static void DrawMesh (Mesh mesh, Matrix4x4 matrix);
Obsolete public static void DrawMesh (Mesh mesh, Matrix4x4 matrix, int materialIndex);
public static void DrawMesh (Mesh mesh, Matrix4x4 matrix, Material material, int layer, Camera camera= null, int submeshIndex= 0, MaterialPropertyBlock properties= null, bool castShadows= true, bool receiveShadows= true, bool useLightProbes= true);
public static void DrawMesh (Mesh mesh, Matrix4x4 matrix, Material material, int layer, Camera camera, int submeshIndex, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows= true, Transform probeAnchor= null, bool useLightProbes= true);

Parameters

mesh @param mesh Mesh, который будет нарисован.
position @param position Местоположение меша.
rotation @param rotation Вращение меша.
materialIndex @param materialIndex Подмножество меша, которые будет нарисовано.
matrix Transformation matrix of the mesh (combines position, rotation and other transformations).
material @param material Используемый Material.
layer @param layer Используемый Слой.
camera @param camera Если null (по умолчанию), меш будет нарисован во всех камерах. В противном случае, меш будет нарисован только в указанной камере.
submeshIndex @param submeshIndex Какое подмножество меша будет нарисовано. Это применимо только для мешей, состоящих из нескольких материалов.
properties @param properties Дополнительное свойство материала. Данное свойство применяется на материале непосредственно до рисования меша. Для получения дополнительной информации смотрите MaterialPropertyBlock.
castShadows @param castShadows Будет ли меш порождать тени?
receiveShadows @param receiveShadows Будет ли меш принимать тени?
useLightProbes @param castShadows Будет ли меш порождать тени?
probeAnchor If used, the mesh will use this Transform's position to sample light probes and find the matching reflection probe.

Description

Рисует меш.

DrawMesh draws a mesh for one frame. The mesh will be affected by the lights, can cast and receive shadows and be affected by Projectors - just like it was part of some game object. It can be drawn for all cameras or just for some specific camera.

Use DrawMesh in situations where you want to draw large amount of meshes, but don't want the overhead of creating and managing game objects. Note that DrawMesh does not draw the mesh immediately; it merely "submits" it for rendering. The mesh will be rendered as part of normal rendering process. If you want to draw a mesh immediately, use Graphics.DrawMeshNow.

Because DrawMesh does not draw mesh immediately, modifying material properties between calls to this function won't make the meshes pick up them. If you want to draw series of meshes with the same material, but slightly different properties (e.g. change color of each mesh), use MaterialPropertyBlock parameter.

Note that this call will create some internal resources while the mesh is queued up for rendering. The allocation happens immediatly and will be kept around until the end of frame (if the object was queued for all cameras) or until the specified camera renders itself.

See Also: MaterialPropertyBlock.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Mesh mesh; public Material material; public void Update() { // will make the mesh appear in the scene at origin position Graphics.DrawMesh(mesh, Vector3.zero, Quaternion.identity, material, 0); } }