Draw a line from p1 to p2.
Draw Line in the Scene view.
The following example uses DrawLine to draw a line between a GameObject and the GameObjects defined in a list.
To use this example, save the following script into the Assets/Editor folder:
using UnityEngine; using UnityEditor;
[CustomEditor( typeof( DrawLine ) )] public class DrawLineEditor : Editor { void OnSceneGUI( ) { DrawLine t = target as DrawLine;
if( t == null || t.GameObjects == null ) return;
Vector3 center = t.transform.position;
for( int i = 0; i < t.GameObjects.Length; i++ ) { if( t.GameObjects[i] != null ) Handles.DrawLine( center, t.GameObjects[i].transform.position ); } } }
...then attach this script to the anchor GameObject which you would like to see lines come from. Drop GameObjects you would like the lines to go to into the array in the script's inspector:
using UnityEngine;
[ExecuteInEditMode] public class DrawLine : MonoBehaviour { public GameObject[] GameObjects; }