返回介绍

Graphics.DrawMesh

发布于 2019-12-18 15:37:44 字数 8680 浏览 996 评论 0 收藏 0

JavaScript => public static function DrawMesh(mesh: Mesh, position: Vector3, rotation: Quaternion): void;
JavaScript =>public static function DrawMesh(mesh: Mesh, position: Vector3, rotation: Quaternion, materialIndex: int): void;
JavaScript =>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;
JavaScript =>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;
JavaScript =>public static function DrawMesh(mesh: Mesh, matrix: Matrix4x4): void;
JavaScript =>public static function DrawMesh(mesh: Mesh, matrix: Matrix4x4, materialIndex: int): void;
JavaScript =>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;
JavaScript =>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;
C# => public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation);
C# =>public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation, int materialIndex);
C# =>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);
C# =>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);
C# =>public static void DrawMesh(Mesh mesh, Matrix4x4 matrix);
C# =>public static void DrawMesh(Mesh mesh, Matrix4x4 matrix, int materialIndex);
C# =>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);
C# =>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);

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.
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.
castShadowsShould the mesh cast shadows?
receiveShadowsShould the mesh receive shadows?

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参数。

JavaScript:

#pragma strict
public var mesh: Mesh;
public var material: Material;
public function Update() {
	// will make the mesh appear in the scene at origin position
	Graphics.DrawMesh(mesh, Vector3.zero, Quaternion.identity, material, 0);
}

C#:

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

graphics

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文