Assets.NodeEditor.Editor.NodeHandle.CalculatePosition C# (CSharp) Method

CalculatePosition() private method

Calculate the new offset position of the handle depending on the orientation and offset
private CalculatePosition ( ) : void
return void
        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;
            }
        }