private void DeleteWaypoint(KeyDownEvent e, WaypointElement pointVisual) { e.StopPropagation(); if (e.keyCode == KeyCode.Delete && pointVisual != null) { if (!pointElements.Contains(pointVisual)) { return; } //Remove it from the view box.Remove(pointVisual); int index = pointElements.IndexOf(pointVisual); //If the point to be deleted is the currently selected point then deselect it if (selectedVisualPoint == pointVisual) { selectedVisualPoint = null; } //Remove it from the data structures pointElements.Remove(pointVisual); t.points.RemoveAt(index); serializedObject.Update(); MarkSceneAsDirty(); //Rename points for (int i = 0; i < pointElements.Count; i++) { pointElements[i].Rename(i.ToString()); } } }
private void CreateWaypointElement(string _name, Waypoint waypoint) { var pointVisual = new WaypointElement(); pointVisual.Initialize(_name, waypoint); pointVisual.RegisterCallback <KeyDownEvent, WaypointElement>(DeleteWaypoint, pointVisual); box.Add(pointVisual); pointElements.Add(pointVisual); }
private void ClearWaypoints() { t.points.Clear(); serializedObject.Update(); foreach (var p in pointElements) { box.Remove(p); } pointElements.Clear(); selectedVisualPoint = null; }
private void OnBoxClicked(MouseDownEvent e) { e.StopPropagation(); selectedVisualPoint = null; }
private void OnWaypointClicked(WaypointElement waypoint) { selectedVisualPoint = waypoint; }