Graphics.DrawMesh 绘制网格
static function DrawMesh (mesh : Mesh, position : Vector3, rotation : Quaternion, material : Material, layer : int, camera : Camera = null, submeshIndex : int = 0, properties : MaterialPropertyBlock = null) : void
static function DrawMesh (mesh : Mesh, matrix : Matrix4x4, material : Material, layer : int, camera : Camera = null, submeshIndex : int = 0, properties : MaterialPropertyBlock = null) : void
Parameters参数
- meshThe Mesh to draw.
用来绘制的网格。 - positionPosition of the mesh.
网格的位置。 - rotationRotation of the mesh.
网格的旋转。 - matrixTransformation matrix of the mesh (combines position, rotation and other transformations).
网格的变换矩阵(组合位置,旋转和其他变换) - materialMaterial to use.
使用的材质。 - layerLayer to use.
使用的层。 - cameraIf null (default), the mesh will be drawn in all cameras. Otherwise it will be rendered in the given camera only.
如果是null(缺省),该网格将在所有相机中被绘制,否则它将只会在给定的相机中渲染。 - submeshIndexWhich subset of the mesh to draw. This applies only to meshes that are composed of several materials.
绘制哪个子网格。这只在网格使用了多个材质的时候使用。 - propertiesAdditional material properties to apply onto material just before this mesh will be drawn. See MaterialPropertyBlock.
在网格绘制前应用到材质的额外材质属性。
Description描述
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.
DrawMesh 在一帧中绘制一个网格。这个网格将受到光照的影响,可以投射和接收阴影并受投射器影响,就像它是某个游戏物体的一部分。他可以绘制于所有相机或者只在特定的一些相机。
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.
使用DrawMesh的情况,你想绘制大量的网格,而又不想在创建和管理游戏物体的开销。注意,DrawMesh不会立即绘制网格;它仅仅提交它用于渲染。网格将被作为普通渲染过程的一部分。如果想立即绘制一个网格。使用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.
因为DrawMesh不会立即绘制网格,在调用这个函数期间修改材质属性不会使材质指定它们。如果你想绘制一系列相同材质的网格,但是稍微有些不同的属性(例如,改变每个网格的颜色),那么使用MaterialPropertyBlock参数。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Mesh aMesh;
public Material aMaterial;
void Update() {
Graphics.DrawMesh(aMesh, Vector3.zero, Quaternion.identity, aMaterial, 0);
}
}
// Draws aMesh with aMaterial at (0,0,0) with no rotation for one frame
//绘制网格和材质在(0,0,0) 在一帧不带有旋转
var aMesh : Mesh;
var aMaterial : Material;
function Update() {
Graphics.DrawMesh(aMesh, Vector3.zero, Quaternion.identity, aMaterial, 0);
}