Version: 2020.1

CommandBuffer.DrawMeshInstancedProcedural

切换到手册
public void DrawMeshInstancedProcedural (Mesh mesh, int submeshIndex, Material material, int shaderPass, int count, MaterialPropertyBlock properties);

参数

mesh 要绘制的 Mesh
submeshIndex 要绘制网格的哪个子集。这只适用于由若干种材质构成的网格。
material 要使用的 Material
shaderPass 要使用着色器的哪个通道,或选择 -1,表示渲染所有通道。
count 要绘制的实例数。
properties 在绘制此网格之前应用于材质的其他材质属性。请参阅 MaterialPropertyBlock

描述

添加“通过实例化绘制网格”命令。

使用程序实例化绘制网格。这与 Graphics.DrawMeshInstancedIndirect 类似,只不过在从脚本获知实例数量时,可以使用此方法直接提供,而不是通过 ComputeBuffer。 该命令在 Material.enableInstancing 为 false 时不会立即失败并抛出异常,但是如果检测到此类条件,则会在每次执行该命令时记录错误并跳过渲染。

如果当前平台不支持此 API(即,如果 GPU 实例化不可用),则会抛出 InvalidOperationException。请参阅 SystemInfo.supportsInstancing