void SetCircles(AxisInfo axisInfo, AxisVectors axisVectors) { axisVectors.Clear(); if (type == TransformType.Rotate) { float circleLength = handleLength * GetDistanceMultiplier(); AddCircle(target.position, axisInfo.xDirection, circleLength, axisVectors.x); AddCircle(target.position, axisInfo.yDirection, circleLength, axisVectors.y); AddCircle(target.position, axisInfo.zDirection, circleLength, axisVectors.z); AddCircle(target.position, (target.position - transform.position).normalized, circleLength, axisVectors.all, false); } }
void OnPostRender() { if (target == null) { return; } lineMaterial.SetPass(0); Color xColor = (selectedAxis == Axis.X) ? selectedColor : this.xColor; Color yColor = (selectedAxis == Axis.Y) ? selectedColor : this.yColor; Color zColor = (selectedAxis == Axis.Z) ? selectedColor : this.zColor; Color allColor = (selectedAxis == Axis.Any) ? selectedColor : this.allColor; DrawLines(handleLines.x, xColor); DrawLines(handleLines.y, yColor); DrawLines(handleLines.z, zColor); DrawTriangles(handleTriangles.x, xColor); DrawTriangles(handleTriangles.y, yColor); DrawTriangles(handleTriangles.z, zColor); DrawSquares(handleSquares.x, xColor); DrawSquares(handleSquares.y, yColor); DrawSquares(handleSquares.z, zColor); DrawSquares(handleSquares.all, allColor); AxisVectors rotationAxisVector = circlesLines; if (isTransforming && space == TransformSpace.Global && type == TransformType.Rotate) { rotationAxisVector = drawCurrentCirclesLines; AxisInfo axisInfo = new AxisInfo(); axisInfo.xDirection = totalRotationAmount * Vector3.right; axisInfo.yDirection = totalRotationAmount * Vector3.up; axisInfo.zDirection = totalRotationAmount * Vector3.forward; SetCircles(axisInfo, drawCurrentCirclesLines); } DrawCircles(rotationAxisVector.x, xColor); DrawCircles(rotationAxisVector.y, yColor); DrawCircles(rotationAxisVector.z, zColor); DrawCircles(rotationAxisVector.all, allColor); }