mesh | 描画する Mesh |
submeshIndex | 描画するメッシュのサブセット。これはいくつかのマテリアルで構成されるメッシュにのみ適用されます。 |
material | 使用する Material |
matrices | The array of object transformation matrices. |
count | The number of instances to be drawn. |
properties | Additional material properties to apply. See MaterialPropertyBlock. |
castShadows | Determines whether the Meshes should cast shadows. |
receiveShadows | Determines whether the Meshes should receive shadows. |
layer | 使用する Layer |
camera | If 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. |
Draws 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.
This function is now obsolete. Use Graphics.RenderMeshInstanced instead.
Use this function in situations where you want to draw the same mesh for a particular amount of times using an instanced shader. Unity culls and sorts instanced Meshes as a group. It creates an axis-aligned bounding box that contains all the Meshes, calculates the center point, then uses this information to cull and sort the Mesh instances. Note that after culling and sorting the combined instances, Unity does not further cull individual instances by the view frustum or baked occluders. It also does not sort individual instances for transparency or depth 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: Graphics.DrawMesh, Graphics.RenderMeshInstanced.
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.