private void CalculatePosition() {
Rect nodeRect = attachedTo.rect;
float widthHalf = attachedTo.rect.width / 2;
float heightHalf = attachedTo.rect.height / 2;
switch (orientation) {
case HandleOrientation.TOP:
position = new Vector2(Mathf.Clamp(offset, -widthHalf, widthHalf - handleTex.width), -nodeRect.height / 2 - rect.height);
break;
case HandleOrientation.BOTTOM:
position = new Vector2(Mathf.Clamp(offset, -widthHalf, widthHalf - handleTex.width), nodeRect.height / 2);
break;
case HandleOrientation.LEFT:
position = new Vector2(-nodeRect.width / 2 - rect.width, Mathf.Clamp(offset, -heightHalf, heightHalf - handleTex.height));
break;
case HandleOrientation.RIGHT:
position = new Vector2(nodeRect.width / 2, Mathf.Clamp(offset, -heightHalf, heightHalf - handleTex.height));
break;
}
}