Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

Graphics.DrawMesh

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual
public static function DrawMesh(mesh: Mesh, position: Vector3, rotation: Quaternion): void;
public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation);
public static function DrawMesh(mesh: Mesh, position: Vector3, rotation: Quaternion, materialIndex: int): void;
public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation, int materialIndex);
public static function DrawMesh(mesh: Mesh, position: Vector3, rotation: Quaternion, material: Material, layer: int, camera: Camera = null, submeshIndex: int = 0, properties: MaterialPropertyBlock = null, castShadows: bool = true, receiveShadows: bool = true): void;
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);
public static function DrawMesh(mesh: Mesh, position: Vector3, rotation: Quaternion, material: Material, layer: int, camera: Camera, submeshIndex: int, properties: MaterialPropertyBlock, castShadows: Rendering.ShadowCastingMode, receiveShadows: bool = true, probeAnchor: Transform = null): void;
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);
public static function DrawMesh(mesh: Mesh, matrix: Matrix4x4): void;
public static void DrawMesh(Mesh mesh, Matrix4x4 matrix);
public static function DrawMesh(mesh: Mesh, matrix: Matrix4x4, materialIndex: int): void;
public static void DrawMesh(Mesh mesh, Matrix4x4 matrix, int materialIndex);
public static function DrawMesh(mesh: Mesh, matrix: Matrix4x4, material: Material, layer: int, camera: Camera = null, submeshIndex: int = 0, properties: MaterialPropertyBlock = null, castShadows: bool = true, receiveShadows: bool = true): void;
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);
public static function DrawMesh(mesh: Mesh, matrix: Matrix4x4, material: Material, layer: int, camera: Camera, submeshIndex: int, properties: MaterialPropertyBlock, castShadows: Rendering.ShadowCastingMode, receiveShadows: bool = true, probeAnchor: Transform = null): void;
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);

Parámetros

mesh The Mesh to draw.
position Position of the mesh.
rotation Rotation of the mesh.
matrix Transformation matrix of the mesh (combines position, rotation and other transformations).
material Material to use.
layer Layer to use.
camera If null (default), the mesh will be drawn in all cameras. Otherwise it will be rendered in the given camera only.
submeshIndex Which subset of the mesh to draw. This applies only to meshes that are composed of several materials.
properties Additional material properties to apply onto material just before this mesh will be drawn. See MaterialPropertyBlock.
castShadows Should the mesh cast shadows?
receiveShadows Should the mesh receive shadows?

Descripción

Draw a mesh.

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.

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); } }