Draw poliline error

Good day,I have a problem, my polyline does not start from first waypoint,but it seems to start from te parent. You can see the attached image

thi is my Script for drow :

using UnityEngine;
using System.Collections;
using UnityEditor;

   
[CustomEditor(typeof(AIWaypointNetwok))]
public class AIWaypointNetworkEditor : Editor {

    void OnSceneGUI()
    {
        AIWaypointNetwok network = (AIWaypointNetwok)target;
        // I put name to waypoints
        for (int i = 0; i < network.Waypoints.Count; i++)
        {
          
            if(network.Waypoints[i] != null)
            Handles.Label(network.Waypoints[i].position, "Waypoint " + i.ToString());

        }
        //Draw Poliline
        Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];
        for (int i = 0; i <= network.Waypoints.Count; i++)
        {
            int index = i != network.Waypoints.Count ? i : 0;
            if (network.Waypoints[index] != null)
            {
                linePoints[i] = network.Waypoints[index].position;
            }
          
            Handles.color = Color.cyan;
            Handles.DrawPolyLine(linePoints);
           
        }

        }
}

this is AIWaypointNetwok:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class AIWaypointNetwok : MonoBehaviour {

    public List<Transform> Waypoints = new List<Transform>();
   
}

i’d guess one of them is not set (so its default vector3.zero)

try printing out the values for each point, which index it is?

I tried to do this but it always goes in loop, but starts from 0, I’m not very expert sorry, I should print the title not the name of the object, how could I do?

//Draw Poliline
        Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];
        for (int i = 0; i <= network.Waypoints.Count; i++)
        {
            int index = i != network.Waypoints.Count ? i : 0;
            if (network.Waypoints[index] != null)
            {
                linePoints[i] = network.Waypoints[index].position;
             
               Debug.Log("This is numeration  to weapoints " + index);
            }
          
            Handles.color = Color.cyan;
            Handles.DrawPolyLine(linePoints);
           
        }

5170547--513032--Loop.JPG

try printing position also, so can see which one is 0,0,0,

Debug.Log(“This is numeration to waypoints " + index + " pos=”+linePoints*);*
also this one creates array of linepoints, which is +1 larger than waypoints count?
```csharp

  •    Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];*
    

```

this is result:

5170703--513071--unity.PNG

sorry forgot ,
```csharp

  • Debug.Log(“This is numeration to waypoints " + index + " pos=”+linePoints[i]);*
    ```

the positions seem to me correct, I leave the link of the project if someone wants to take a look I am following a course and uses unity 5.02

i think the issue is that you create linePoints array, and its bigger than Waypoints.count,
so you get one empty value there.

I had put these two lines inside the for loop, I moved them outside and everything works thanks a lot for your patience

 Handles.color = Color.cyan;
            Handles.DrawPolyLine(linePoints)