mesh | 要绘制的 Mesh。 |
position | 网格的位置。 |
rotation | 网格的旋转。 |
matrix | 网格的变换矩阵(组合了位置、旋转和其他变换)。 |
material | 要使用的 Material。 |
layer | 要使用的 Layer。 |
camera | 如果为 /null/(默认值),将在所有摄像机中绘制网格。否则,仅在给定摄像机中渲染网格。 |
submeshIndex | 要绘制网格的哪个子集。这只适用于由若干种材质构成的网格。 |
properties | 在绘制此网格之前应用于材质的其他材质属性。请参阅 MaterialPropertyBlock。 |
castShadows | 确定网格是否可以投射阴影。 |
receiveShadows | 确定网格是否可以接受阴影。 |
useLightProbes | 网格是否应使用光照探针? |
probeAnchor | 如果使用,网格将使用该变换组件的位置对光照探针进行采样,并找到匹配的反射探针。 |
lightProbeUsage | 网格的 LightProbeUsage。 |
绘制一个网格。
DrawMesh 为一帧绘制一个网格。网格可以投射和接受阴影,
并受到光照和投影器的影响 - 它就像是某些游戏对象的一部分。可以为所有摄像机或
只为某些特定摄像机绘制网格。
如果您需要绘制大量网格但又不希望出现创建和管理游戏对象的开销,
则可以使用 DrawMesh。注意,DrawMesh 不立即绘制网格;它只“提交”网格以进行渲染。网格
将作为正常渲染过程的一部分进行渲染。若要立即绘制网格,请使用 Graphics.DrawMeshNow。
DrawMesh 不立即绘制网格,因此如果您在该函数调用之间修改材质属性,
网格不会收到这些更改。若要绘制一系列具有相同材质但属性略有不同(例如,更改每个网格的颜色)的网格,
请使用 MaterialPropertyBlock 参数。
注意,在网格排队等待渲染时,该调用将创建一些内部资源。该分配立即执行,并将保留到帧结束(如果对象排队等待所有摄像机),或直到指定摄像机渲染自身。
另请参阅: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); } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.