Following method crops as per displayed cropping area TopLine.SetPosition(1, new Vector3(endPoint.x, startPoint.y, 0)) īottomLine.SetPosition(0, new Vector3(startPoint.x, endPoint.y, 0)) īottomLine.SetPosition(1, new Vector3(endPoint.x, endPoint.y, 0)) TopLine.SetPosition(0, new Vector3(startPoint.x, startPoint.y, 0)) RightLine.SetPosition(1, new Vector3(endPoint.x, startPoint.y, 0)) RightLine.SetPosition(0, new Vector3(endPoint.x, endPoint.y, 0)) LeftLine.SetPosition(1, new Vector3(startPoint.x, startPoint.y, 0)) LeftLine.SetPosition(0, new Vector3(startPoint.x, endPoint.y, 0)) Following method draws rectangle that displays cropping area If(isMousePressed & isSpriteTouched(spriteToCrop))ĮndPoint = (Input.mousePosition) If(Input.GetMouseButtonDown(0) & isSpriteTouched(spriteToCrop)) LineRenderer line = lineObject.AddComponent() GameObject lineObject = new GameObject(lineName) Private LineRenderer createAndGetLine (string lineName) ![]() Creates line through LineRenderer component ![]() RightLine = createAndGetLine("RightLine") īottomLine = createAndGetLine("BottomLine") Private LineRenderer leftLine, rightLine, topLine, bottomLine Rectangle that will display cropping area Reference for sprite which will be cropped and it has BoxCollider or BoxCollider2D
0 Comments
Leave a Reply. |