Question by
Clenpoppenk · Nov 20, 2018 at 10:31 PM ·
editoreditor-scriptingsceneview
How is my waypoint line going back to the gameobject it is stored in and not to the waypoint 0
using System.Collections; using UnityEngine; using UnityEditor;
[ CustomEditor(typeof(AIWaypointNetwork)) ]
public class NewBehaviourScript : Editor
{
void OnSceneGUI()
{
AIWaypointNetwork network = (AIWaypointNetwork)target;
for (int i=0; i<network.Waypoints.Count;i++)
{
if (network.Waypoints[i] != null)
Handles.Label(network.Waypoints[i].position, "Waypoint "+ i.ToString());
}
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;
else
linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
}
Handles.color = Color.cyan;
Handles.DrawPolyLine(linePoints);
}
}
}
what am i doing wrong here i need help?
unity-help.jpg
(249.5 kB)
Comment