# SetVertexCount(int)

> Set the number of line segments.

## Definition

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

> **Warning:**
>
> **Deprecated.** Use positionCount instead.

```csharp
public void SetVertexCount(int count)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)):&#x20;

### Remarks

Additional Resources: [LineRenderer.SetPosition](/engine/6000.7/script-reference/unityengine/linerenderer/setposition.md) function.

Additional Resources: [LineRenderer.SetPositions](/engine/6000.7/script-reference/unityengine/linerenderer/setpositions.md) function.

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    // Creates a line renderer that follows a Sin() function
    // and animates it.

    Color c1 = Color.yellow;
    Color c2 = Color.red;
    int lengthOfLineRenderer = 20;

    void Start()
    {
        LineRenderer lineRenderer = gameObject.AddComponent<LineRenderer>();
        lineRenderer.material = new Material(Shader.Find("Sprites/Default"));
        lineRenderer.SetColors(c1, c2);
        lineRenderer.SetWidth(0.2f, 0.2f);
        lineRenderer.SetVertexCount(lengthOfLineRenderer);
    }

    void Update()
    {
        LineRenderer lineRenderer = GetComponent<LineRenderer>();
        var points = new Vector3[lengthOfLineRenderer];
        var t = Time.time;
        for (int i = 0; i < lengthOfLineRenderer; i++)
        {
            points[i] = new Vector3(i * 0.5f, Mathf.Sin(i + t), 0);
        }
        lineRenderer.SetPositions(points);
    }
}
```
