# RenderSprite(in RenderParams, in SpriteParams, int, Matrix4x4)

> Renders a sprite with the provided rendering parameters and sprite parameters.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## RenderSprite(RenderParams, SpriteParams, int, Matrix4x4)

```csharp
public static void RenderSprite(in RenderParams renderParams, in SpriteParams spriteParams, int submeshIndex, Matrix4x4 objectToWorld)
```

### Parameters

**** (\[RenderParams]\(/engine/6000.7/script-reference/unityengine/renderparams)): **** (\[SpriteParams]\(/engine/6000.7/script-reference/unityengine/spriteparams)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of a submesh Unity renders when the sprite contains multiple materials (submeshes). For a sprite with a single material, use value 0.**** (\[Matrix4x4]\(/engine/6000.7/script-reference/unityengine/matrix4x4)): The transformation matrix Unity uses to transform the sprite from object space to world space.

### Remarks

`RenderSprite` renders a sprite for the current frame. This sprite is affected by 2D lights and sprite masks, but doesn't support shadows. All cameras can render the sprite, or a specific camera.

Use `RenderSprite` to control sprite rendering programmatically without the need to create and manage GameObjects. `RenderSprite` submits the sprite for rendering, which means it doesn't render the sprite immediately. Unity renders the sprite as part of normal rendering process, and is compatible with SRP Batcher and GPU Instancing.

To change the color of each sprite or use sprite mask interaction, use the [SpriteParams](/engine/6000.7/script-reference/unityengine/spriteparams.md) parameter.

This method creates internal resources while the sprite is in the render queue. The allocation happens immediately and exists until the end of frame if the object is in the render queue for all cameras. Otherwise, the allocation exists until the specified camera finishes rendering.

The following example renders 10 Sprites with a given material:

### Examples

```csharp
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public Material material;
    public Sprite sprite;

    void Update()
    {
        RenderParams rp = new RenderParams(material);
        SpriteParams sp = new SpriteParams(sprite);
        for (int i = 0; i < 10; ++i)
            Graphics.RenderSprite(rp, sp, 0, Matrix4x4.Translate(new Vector3(-4.5f+i, 0.0f, 5.0f)));
    }
}
```
