コード例 #1
0
    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());
            }
        }
    }
コード例 #2
0
    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);
    }
コード例 #3
0
 private void ClearWaypoints()
 {
     t.points.Clear();
     serializedObject.Update();
     foreach (var p in pointElements)
     {
         box.Remove(p);
     }
     pointElements.Clear();
     selectedVisualPoint = null;
 }
コード例 #4
0
 private void OnBoxClicked(MouseDownEvent e)
 {
     e.StopPropagation();
     selectedVisualPoint = null;
 }
コード例 #5
0
 private void OnWaypointClicked(WaypointElement waypoint)
 {
     selectedVisualPoint = waypoint;
 }