파라미터

meshThe Mesh to draw.
submeshIndexWhich subset of the mesh to draw. This applies only to meshes that are composed of several materials.
material Material to use.
matricesThe array of object transformation matrices.
countThe number of instances to be drawn.
propertiesAdditional material properties to apply. See MaterialPropertyBlock.
castShadowsShould the meshes cast shadows?
receiveShadowsShould the meshes receive shadows?
layer Layer to use.
cameraIf null (default), the mesh will be drawn in all cameras. Otherwise it will be drawn in the given camera only.
lightProbeUsage LightProbeUsage for the instances.

설명

Draw the same mesh multiple times using GPU instancing.

Similar to Graphics.DrawMesh, this function draws meshes for one frame without the overhead of creating unnecessary game objects.

Use this function in situations where you want to draw the same mesh for a particular amount of times using an instanced shader. Meshes are not further culled by the view frustum or baked occluders, nor sorted for transparency or z efficiency.

The transformation matrix of each instance of the mesh should be packed into the matrices array. You can specify the number of instances to draw, or by default it is the length of the matrices array. Other per-instance data, if required by the shader, should be provided by creating arrays on the MaterialPropertyBlock argument using SetFloatArray, SetVectorArray and SetMatrixArray.

To render the instances with light probes, provide the light probe data via the MaterialPropertyBlock and specify lightProbeUsage with LightProbeUsage.CustomProvided. Check LightProbes.CalculateInterpolatedLightAndOcclusionProbes for the details.

Note: You can only draw a maximum of 1023 instances at once.

InvalidOperationException will be thrown if the material doesn't have Material.enableInstancing set to true, or the current platform doesn't support this API (i.e. if GPU instancing is not available). See SystemInfo.supportsInstancing.

See Also: DrawMesh.