// ----------------------------------- void UpdateCurvedLine() { // If mouse button down, remove old line and set its color to green if (Input.GetMouseButtonDown(0)) { //check if there is no line renderer created if (currentLine == null) { //create the line currentLine = createNewStraightLineLine(); } pointsList = new List <Vector3>(); } else if (Input.GetMouseButtonUp(0) && currentLine) { //set line as null once the line is created currentLine = null; } // Drawing line when mouse is moving(presses) if (Input.GetMouseButton(0) && currentLine) { mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); mousePos.z = 0; if (pointsList.Count == 0 || !MathUtilsExt.V3Equal(pointsList[pointsList.Count - 1], mousePos)) { pointsList.Add(mousePos); currentLine.positionCount = pointsList.Count; currentLine.SetPosition(pointsList.Count - 1, (Vector3)pointsList[pointsList.Count - 1]); } } }
void OnDrawing() { if (currentLine) { Vector3 pos = CursorManager.Instance.ActiveCursor.transform.position; //pos.z = 0; if (pointsList.Count == 0 || !MathUtilsExt.V3Equal(pointsList[pointsList.Count - 1], pos)) { pointsList.Add(pos); currentLine.positionCount = pointsList.Count; currentLine.SetPosition(pointsList.Count - 1, pointsList[pointsList.Count - 1]); } } else { StartDrawing(); } }
void OnDrawing(Vector3 cumulativeDelta, Vector3 headPosition) { if (currentLine) { Vector3 move = cumulativeDelta - manipulationDelta; Vector3 handPosition; if (GazeGestureUtils.GetManipulationHandPosition(out handPosition)) { Vector3 fromHeadToModel = myPos - headPosition; Vector3 fromHeadToHand = handPosition - headPosition; float moveAmplifier = fromHeadToModel.magnitude / fromHeadToHand.magnitude; if (moveAmplifier > 1) { move *= moveAmplifier; } myPos += move; } CursorManager.Instance.ActiveCursor.transform.position = myPos; Vector3 pos = myPos; if (pointsList.Count == 0 || !MathUtilsExt.V3Equal(pointsList[pointsList.Count - 1], pos)) { pointsList.Add(pos); currentLine.positionCount = pointsList.Count; currentLine.SetPosition(pointsList.Count - 1, pointsList[pointsList.Count - 1]); } } else { StartDrawing(cumulativeDelta, headPosition); } manipulationDelta = cumulativeDelta; }