protected override void Awake() { base.Awake(); void _addCircle(Color color, Vector3 angles) => LineHelper.drawCircle(addLine(color)).transform.localEulerAngles = angles; _addCircle(Color.green, Vector3.zero); _addCircle(Color.red, new Vector3(0f, 0f, 90f)); _addCircle(Color.blue, new Vector3(90f, 0f, 0f)); }
void redrawCapsule() { float length = Mathf.Max(0f, height / 2 - radius); // distance between the centers of the hemispheres Vector3 posHemi = new (length, 0f, 0f); Vector3 negHemi = new (-length, 0f, 0f); void _drawCircle(int index, Vector3 pos, int angle) { var line = getLine(index); line.transform.localPosition = pos; LineHelper.drawCircle(line, angle, radius); } _drawCircle(0, posHemi, 360); _drawCircle(1, posHemi, 180); _drawCircle(2, posHemi, 180); _drawCircle(3, negHemi, 360); _drawCircle(4, negHemi, 180); _drawCircle(5, negHemi, 180); if (length > 0f) { void _setPoints(int index, float y, float z) => getLine(index).setPoints(new Vector3(length, y, z), new Vector3(-length, y, z)); _setPoints(6, -radius, 0f); _setPoints(7, radius, 0f); _setPoints(8, 0f, -radius); _setPoints(9, 0f, radius); } else { for (int i = 6; i <= 9; i++) { getLine(i).enabled = false; } } }