DrawLineList(ReadOnlySpan<Vector3>)
Draws multiple lines between pairs of points.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public static void DrawLineList(ReadOnlySpan<Vector3> points)
Parameters
Pairs of points to use as the beginning and end of each line to draw. Unity throws an exception if contains an odd number of elements.
pointsRemarks
This function provides a more efficient way to draw multiple lines than repeatedly calling the Gizmos.DrawLine function for each one.
Each pair of points from the span represents the start and end of each line, so Unity draws the first line from to , the next from to , and so on.
pointspoints[0]points[1]points[2]points[3]using UnityEngine;using System.Collections;public class ExampleClass : MonoBehaviour{ Vector3[] points; void Start() { points = new Vector3[4] { new Vector3(-100, 0, 0), new Vector3(100, 0, 0), new Vector3(-100, 100, 0), new Vector3(100, 100, 0) }; } void OnDrawGizmosSelected() { // Draws two parallel blue lines Gizmos.color = Color.blue; Gizmos.DrawLineList(points); }}
Additional Resources: Gizmos.DrawLine, Gizmos.DrawLineStrip.