protected override void OnEnable() { base.OnEnable(); _targ = this.target as WaypointPathComponent; _nodesProp = this.serializedObject.FindProperty(PROP_WAYPOINTS); _nodeList = new SPReorderableList(this.serializedObject, _nodesProp); _nodeList.elementHeight = EditorGUIUtility.singleLineHeight; _nodeList.drawHeaderCallback = _nodeList_DrawHeader; _nodeList.drawElementCallback = _nodeList_DrawElement; _nodeList.onAddCallback = _nodeList_OnAdded; _currentNodes = this.GetCurrentNodes(); _lastNodeCache.Clear(); _lastNodeCache.AddRange(_currentNodes); }
private static void OnDrawGizmos(WaypointPathComponent c, GizmoType gizmoType) { if (gizmoType.HasFlag(GizmoType.NotInSelectionHierarchy) && !c.transform.IsParentOf(Selection.activeTransform)) { return; } var path = WaypointPathComponent.GetPath(c, false); if (path == null || path.Count == 0) { return; } var matrix = (c.started && c.TransformRelativeTo != null) ? Matrix4x4.TRS(c.TransformRelativeTo.position, c.TransformRelativeTo.rotation, Vector3.one) : Matrix4x4.identity; Gizmos.color = Color.red; using (var pnts = com.spacepuppy.Collections.TempCollection.GetList <Vector3>()) { path.GetDetailedPositions(pnts, SEG_LENGTH); for (int i = 1; i < pnts.Count; i++) { Gizmos.DrawLine(matrix.MultiplyPoint3x4(pnts[i - 1]), matrix.MultiplyPoint3x4(pnts[i])); } } IWaypoint pnt; Gizmos.color = Color.green; pnt = path.ControlPoint(0); Gizmos.DrawWireCube(matrix.MultiplyPoint3x4(pnt.Position), Vector3.one * 0.5f); if (path.Count > 1) { Gizmos.color = Color.yellow; for (int i = 1; i < path.Count - 1; i++) { pnt = path.ControlPoint(i); Gizmos.DrawWireSphere(matrix.MultiplyPoint3x4(pnt.Position), 0.25f); } Gizmos.color = Color.red; pnt = path.ControlPoint(path.Count - 1); Gizmos.DrawWireCube(matrix.MultiplyPoint3x4(pnt.Position), Vector3.one * 0.5f); } }