UnityEngine.Graphics.DrawMeshInstanced C# (CSharp) Method

DrawMeshInstanced() public static method

Draw the same mesh multiple times using GPU instancing.

public static DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, Matrix4x4 matrices, [ count, [ properties, [ castShadows, [ receiveShadows, [ layer, [ camera ) : void
mesh Mesh The Mesh to draw.
submeshIndex int Which subset of the mesh to draw. This applies only to meshes that are composed of several materials.
material Material Material to use.
matrices Matrix4x4 The array of object transformation matrices.
count [ The number of instances to be drawn.
properties [ Additional material properties to apply. See MaterialPropertyBlock.
castShadows [ Should the mesh cast shadows?
receiveShadows [ Should the mesh receive shadows?
layer [ to use.
camera [ If null (default), the mesh will be drawn in all cameras. Otherwise it will be drawn in the given camera only.
return void
        public static void DrawMeshInstanced(Mesh mesh, int submeshIndex, Material material, Matrix4x4[] matrices, [UnityEngine.Internal.DefaultValue("matrices.Length")] int count, [UnityEngine.Internal.DefaultValue("null")] MaterialPropertyBlock properties, [UnityEngine.Internal.DefaultValue("ShadowCastingMode.On")] ShadowCastingMode castShadows, [UnityEngine.Internal.DefaultValue("true")] bool receiveShadows, [UnityEngine.Internal.DefaultValue("0")] int layer, [UnityEngine.Internal.DefaultValue("null")] Camera camera)
        {
            if (!SystemInfo.supportsInstancing)
            {
                throw new InvalidOperationException("Instancing is not supported.");
            }
            if (mesh == null)
            {
                throw new ArgumentNullException("mesh");
            }
            if ((submeshIndex < 0) || (submeshIndex >= mesh.subMeshCount))
            {
                throw new ArgumentOutOfRangeException("submeshIndex", "submeshIndex out of range.");
            }
            if (material == null)
            {
                throw new ArgumentNullException("material");
            }
            if (matrices == null)
            {
                throw new ArgumentNullException("matrices");
            }
            if ((count < 0) || (count > Mathf.Min(kMaxDrawMeshInstanceCount, matrices.Length)))
            {
                throw new ArgumentOutOfRangeException("count", string.Format("Count must be in the range of 0 to {0}.", Mathf.Min(kMaxDrawMeshInstanceCount, matrices.Length)));
            }
            if (count > 0)
            {
                Internal_DrawMeshInstanced(mesh, submeshIndex, material, matrices, count, properties, castShadows, receiveShadows, layer, camera);
            }
        }

Same methods

Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, List matrices ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, List matrices, MaterialPropertyBlock properties ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, List matrices, MaterialPropertyBlock properties, ShadowCastingMode castShadows ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, List matrices, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, List matrices, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, int layer ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, List matrices, [ properties, [ castShadows, [ receiveShadows, [ layer, [ camera ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, Matrix4x4 matrices ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, Matrix4x4 matrices, int count ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, Matrix4x4 matrices, int count, MaterialPropertyBlock properties ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, Matrix4x4 matrices, int count, MaterialPropertyBlock properties, ShadowCastingMode castShadows ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, Matrix4x4 matrices, int count, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows ) : void
Graphics::DrawMeshInstanced ( Mesh mesh, int submeshIndex, Material material, Matrix4x4 matrices, int count, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, int layer ) : void

Usage Example

Example #1
0
        public static void DrawMeshInstanced(Mesh mesh, int submeshIndex, Material material, List <Matrix4x4> matrices, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows)
        {
            Camera camera = null;
            int    layer  = 0;

            Graphics.DrawMeshInstanced(mesh, submeshIndex, material, matrices, properties, castShadows, receiveShadows, layer, camera);
        }
All Usage Examples Of UnityEngine.Graphics::DrawMeshInstanced