private void Start() { _platform = GetComponent <Rigidbody>(); _platform.isKinematic = true; _waypoints = new SelectList <Vector3>(waypoints); _currentWaypoint = _waypoints.GetSelected(); }
private void OnSceneGUI() { HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)); for (var i = 0; i < _waypoints.Count; i++) { var current = _waypoints.Items[i]; var nextIndex = i + 1; Handles.color = _waypoints.IsSelected(i) ? Color.yellow : Color.red; _waypoints.Items[i] = Handles.FreeMoveHandle( current, Quaternion.identity, _freeMoveHandleRadius, Vector3.zero, Handles.SphereHandleCap); Handles.color = Color.green; var waypoint = _waypoints.GetSelected(); var handle = Handles.DoPositionHandle(waypoint, Quaternion.identity); _waypoints.UpdateSelected(handle); if (nextIndex < _waypoints.Count) { Handles.DrawLine(current, _waypoints.Items[nextIndex]); } if (Event.current.type == EventType.Used) { var distance = HandleUtility.DistanceToCircle(current, _freeMoveHandleRadius); if (distance <= _freeMoveHandleRadius) { _waypoints.Select(i); Repaint(); } } } }
private void SelectNextWaypoint() { _waypoints.SelectNext(_isReversed, true); _currentWaypoint = _waypoints.GetSelected(); }