11 public override int NumPoints
19 public override bool Loops
29 [Header(
"Rectangle Settings")]
31 private Vector3[] points;
78 private float xSize = 1f;
81 private float ySize = 1f;
84 private float zOffset = 0f;
93 if (points == null || points.Length != 8)
95 points =
new Vector3[8];
105 if (points == null || points.Length != 8)
107 points =
new Vector3[8];
110 if (pointIndex <= 7 && pointIndex >= 0)
112 points[pointIndex] = point;
118 if (points == null || points.Length != 8)
120 points =
new Vector3[8];
123 if (pointIndex <= 7 && pointIndex >= 0)
125 return points[pointIndex];
135 Vector3 last = points[0];
137 for (
int i = 1; i < points.Length; i++)
139 distance += Vector3.Distance(last, points[i]);
148 return (GetPoint(normalizedLength) - transform.position).normalized;
151 private void BuildPoints()
153 Vector3 offset = Vector3.forward * ZOffset;
154 Vector3 top = (Vector3.up * YSize * 0.5f);
155 Vector3 bot = (Vector3.down * YSize * 0.5f);
156 Vector3 left = (Vector3.left * XSize * 0.5f);
157 Vector3 right = (Vector3.right * XSize * 0.5f);
159 SetPointInternal(0, top + left + offset);
160 SetPointInternal(1, top + offset);
161 SetPointInternal(2, top + right + offset);
162 SetPointInternal(3, right + offset);
163 SetPointInternal(4, bot + right + offset);
164 SetPointInternal(5, bot + offset);
165 SetPointInternal(6, bot + left + offset);
166 SetPointInternal(7, left + offset);
171 public class CustomEditor : LineBaseEditor
177 protected override void OnDrawGizmos()
182 if (Application.isPlaying)
187 if (
UnityEditor.Selection.activeGameObject ==
this.gameObject)
199 Vector3 firstPos = GetPoint(0);
200 Vector3 lastPos = firstPos;
201 Gizmos.color = Color.Lerp(LineBaseEditor.DefaultDisplayLineColor, Color.clear, 0.25f);
203 for (
int i = 1; i < NumPoints; i++)
205 Vector3 currentPos = GetPoint(i);
206 Gizmos.DrawLine(lastPos, currentPos);
207 lastPos = currentPos;
210 Gizmos.DrawLine(lastPos, firstPos);