- Home /
why Gizmos.DrawLine() not working here?
Hi there I'm trying to run the below script on unity 5.3 the script is working fine on unity 3.5.3 but no longer on 5.3 after spending a lot of time am not able to figure out how to make it work please attach the script to empty object which has two children
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class PathScript : MonoBehaviour
{
List<Transform> path;
Color rayColor = Color.white;
void OnDrawGizmos()
{
Gizmos.color = rayColor;
Transform[] path_objs;
path_objs = transform.GetComponentsInChildren<Transform>();
path = new List<Transform>();
foreach (Transform path_obj in path_objs)
{
if (path_obj != transform)
{
path.Add(path_obj);
}
}
for (int i = 0; i < path.Count; i++)
{
Vector3 pos = path[i].position;
if (i > 0)
{
Vector3 prev = path[i - 1].position;
Gizmos.DrawLine(prev, pos); // ??
Gizmos.DrawWireSphere(pos, 0.6f);
}
}
}
}
pth.jpg
(2.7 kB)
Comment
Do you have gizmos enabled in the scene view? Script is working fine for me.
Best Answer
Answer by Jessespike · Apr 11, 2016 at 06:07 PM
Gizmos need to be enabled in the scene view.