public void Start(Point mousePosition, ObservableCollection <ItemModel> items) { _zoneSelection = new PathGeometry(); _pathFigure = new PathFigure(); _pathFigure.StartPoint = new Point(mousePosition.X, mousePosition.Y); _pathFigure.IsClosed = true; _minX = mousePosition.X; _maxX = mousePosition.X; _minY = mousePosition.Y; _maxY = mousePosition.Y; ItemModel item = new ItemModel() { Type = "lasso", Left = 0, Top = 0, Geometry = ZoneSelection.ToString(), Visibility1 = "Hidden", StrokeDashArray = "4, 2", StrokeThickness = "3" }; items.Add(item); RectangleSelection = item; }
private void deselectLastZone() { //If any zone was selected if (SelectedZone != null) { //Delelect it SelectedZone.GetComponent <ZoneSelection>().Deselect(); } SelectedZone = null; }
void TrySelectZone() { RaycastHit hitResult; LayerMask layerMask = LayerMask.GetMask("Continent", "Planet"); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hitResult, Mathf.Infinity, layerMask)) { ZoneSelection newSelectedZone = hitResult.transform.GetComponent <ZoneSelection>(); // If Clicked on a zone and it is different from already Selected Zone if (newSelectedZone != null && newSelectedZone != SelectedPlanet) { // Make sure the user does not select zone From Another Planet if (SelectedPlanet == null || newSelectedZone.GetComponentInParent <Planet>() != SelectedPlanet) { return; } //Deselect Previous Zone if (SelectedZone != null) { SelectedZone.GetComponent <ZoneSelection>().Deselect(); } //If clicking on the selected zone if (SelectedZone == newSelectedZone) { deselectLastZone(); return; } SelectedZone = newSelectedZone; newSelectedZone.GetComponent <ZoneSelection>().Select(); //hitResult.normal ZoomToRegion(hitResult); OnSelectZone?.Invoke(); } else if (newSelectedZone == null) { deselectLastZone(); } } }