/// <summary> /// Initiates a rectangle selection operation. /// </summary> /// <returns>The rectangle selection.</returns> public GameObject RectangleSelectionInitiate(OnRectangleSelection rectangleSelectionCallback, Color rectangleFillColor, Color rectangleColor, float lineWidth = 0.02f) { RectangleSelectionCancel(); GameObject rectangle = GameObject.CreatePrimitive(PrimitiveType.Quad); if (rectangleSelectionMat == null) { rectangleSelectionMat = Instantiate(Resources.Load <Material> ("WMSK/Materials/hudRectangleSelection")) as Material; if (disposalManager != null) { disposalManager.MarkForDisposal(rectangleSelectionMat); } } rectangleSelectionMat.color = rectangleFillColor; rectangle.GetComponent <Renderer> ().sharedMaterial = rectangleSelectionMat; AddMarker2DSprite(rectangle, _cursorLocation, 0f); RectangleSelection rs = rectangle.AddComponent <RectangleSelection> (); rs.map = this; rs.callback = rectangleSelectionCallback; rs.lineColor = rectangleColor; rs.lineWidth = lineWidth; if (Input.GetMouseButton(0)) { rs.InitiateSelection(lastMouseMapHitPos.x, lastMouseMapHitPos.y, 0); } return(rectangle); }
public void RectangleSelectionEvent(Bounds rectangle) => OnRectangleSelection?.Invoke(rectangle);