2
\$\begingroup\$
private void OnDrawGizmos()
{
    for(int i = 0; i < waypoints.Count; i++)
    {
        Gizmos.color = Color.green;
        Gizmos.DrawSphere(waypoints[i].position, 0.1f);
    }

    if (nextWayPoint != null)
    {
        Gizmos.color = Color.red;
        Gizmos.DrawLine(transform.position, nextWayPoint.position);
    }
}

It's drawing in color the first two spheres already in the editor but I want it to start drawing the spheres only when running the game not in the editor.

\$\endgroup\$
2
  • \$\begingroup\$ Not sure if this is what you want but In addition to gizmos, you can use Debug functions like Debug.DrawLine directly in your Update routine to do the same sort of thing in-game: docs.unity3d.com/ScriptReference/Debug.DrawLine.html \$\endgroup\$ Nov 28, 2021 at 22:59
  • 1
    \$\begingroup\$ Do you want this for testing, or for the player to see in the released version of the game? If the latter, Gizmos won't do the job, and you'll need to draw your lines with LineRenderers or meshes with a wireframe material instead. \$\endgroup\$
    – DMGregory
    Nov 28, 2021 at 23:01

1 Answer 1

2
\$\begingroup\$
private void OnDrawGizmos()
{
    if(Application.isPlaying)
    {
       //do stuff
    }
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .