private static void SetTriggerPosition(RectTransform t, PinAlignment position)
        {
            var pivotX = 0f;
            var pivotY = 0f;

            var posX = 0f;
            var posY = 0f;

            if (position == PinAlignment.TopLeft || position == PinAlignment.TopRight)
            {
                pivotY = 1f;
                posY   = 1f;
            }
            else if (position == PinAlignment.BottomLeft || position == PinAlignment.BottomRight)
            {
                pivotY = 0f;
                posY   = 0f;
            }

            if (position == PinAlignment.TopLeft || position == PinAlignment.BottomLeft)
            {
                pivotX = 0f;
                posX   = 0f;
            }
            else if (position == PinAlignment.TopRight || position == PinAlignment.BottomRight)
            {
                pivotX = 1f;
                posX   = 1f;
            }

            t.pivot     = new Vector2(pivotX, pivotY);
            t.anchorMax = t.anchorMin = new Vector2(posX, posY);
        }
Exemple #2
0
        private static Rect GetAlignedRect(int width, int height, PinAlignment alignment, Rect workRect)
        {
            var rect = new Rect(0, 0, width, height);

            if (alignment == PinAlignment.BottomLeft || alignment == PinAlignment.BottomRight || alignment == PinAlignment.BottomCenter)
            {
                rect.position = new Vector2(0, workRect.height - rect.height);
            }
            else if (alignment == PinAlignment.CenterLeft || alignment == PinAlignment.CenterRight)
            {
                rect.position = new Vector2(0, workRect.height / 2 - rect.height / 2);
            }

            if (alignment == PinAlignment.TopRight || alignment == PinAlignment.BottomRight || alignment == PinAlignment.CenterRight)
            {
                rect.position += new Vector2(workRect.width - rect.width, 0);
            }
            else if (alignment == PinAlignment.TopCenter || alignment == PinAlignment.BottomCenter)
            {
                rect.position += new Vector2(workRect.width / 2 - rect.width / 2, 0);
            }

            rect.position += workRect.position;

            return(rect);
        }
Exemple #3
0
        private static Rect GetAlignedRect(int width, int height, PinAlignment alignment, Rect workRect)
        {
            var rect = new Rect(0, 0, width, height);

            if (alignment == PinAlignment.BottomLeft || alignment == PinAlignment.BottomRight)
            {
                rect.position = new Vector2(0, workRect.height - rect.height);
            }

            if (alignment == PinAlignment.TopRight || alignment == PinAlignment.BottomRight)
            {
                rect.position += new Vector2(workRect.width - rect.width, 0);
            }

            rect.position += workRect.position;

            return rect;
        }
Exemple #4
0
        public void SetAlignment(PinAlignment alignment)
        {
            _hasSet = true;

            switch (alignment)
            {
            case PinAlignment.TopLeft:
            case PinAlignment.TopRight:
                SetActive(BottomHandle, true);
                SetActive(TopHandle, false);
                SetActive(TopLeftHandle, false);
                SetActive(TopRightHandle, false);
                break;

            case PinAlignment.BottomLeft:
            case PinAlignment.BottomRight:
                SetActive(BottomHandle, false);
                SetActive(TopHandle, true);
                SetActive(BottomLeftHandle, false);
                SetActive(BottomRightHandle, false);
                break;
            }

            switch (alignment)
            {
            case PinAlignment.TopLeft:
            case PinAlignment.BottomLeft:
                SetActive(LeftHandle, false);
                SetActive(RightHandle, true);
                SetActive(TopLeftHandle, false);
                SetActive(BottomLeftHandle, false);
                break;

            case PinAlignment.TopRight:
            case PinAlignment.BottomRight:
                SetActive(LeftHandle, true);
                SetActive(RightHandle, false);
                SetActive(TopRightHandle, false);
                SetActive(BottomRightHandle, false);
                break;
            }

            switch (alignment)
            {
            case PinAlignment.TopLeft:
                SetActive(BottomLeftHandle, false);
                SetActive(BottomRightHandle, true);
                break;

            case PinAlignment.TopRight:
                SetActive(BottomLeftHandle, true);
                SetActive(BottomRightHandle, false);
                break;

            case PinAlignment.BottomLeft:
                SetActive(TopLeftHandle, false);
                SetActive(TopRightHandle, true);
                break;

            case PinAlignment.BottomRight:
                SetActive(TopLeftHandle, true);
                SetActive(TopRightHandle, false);
                break;
            }
        }
        public void SetAlignment(PinAlignment alignment)
        {
            _hasSet = true;

            switch (alignment)
            {
                case PinAlignment.TopLeft:
                case PinAlignment.TopRight:
                    SetActive(BottomHandle, true);
                    SetActive(TopHandle, false);
                    SetActive(TopLeftHandle, false);
                    SetActive(TopRightHandle, false);
                    break;

                case PinAlignment.BottomLeft:
                case PinAlignment.BottomRight:
                    SetActive(BottomHandle, false);
                    SetActive(TopHandle, true);
                    SetActive(BottomLeftHandle, false);
                    SetActive(BottomRightHandle, false);
                    break;
            }

            switch (alignment)
            {
                case PinAlignment.TopLeft:
                case PinAlignment.BottomLeft:
                    SetActive(LeftHandle, false);
                    SetActive(RightHandle, true);
                    SetActive(TopLeftHandle, false);
                    SetActive(BottomLeftHandle, false);
                    break;

                case PinAlignment.TopRight:
                case PinAlignment.BottomRight:
                    SetActive(LeftHandle, true);
                    SetActive(RightHandle, false);
                    SetActive(TopRightHandle, false);
                    SetActive(BottomRightHandle, false);
                    break;
            }

            switch (alignment)
            {
                case PinAlignment.TopLeft:
                    SetActive(BottomLeftHandle, false);
                    SetActive(BottomRightHandle, true);
                    break;

                case PinAlignment.TopRight:
                    SetActive(BottomLeftHandle, true);
                    SetActive(BottomRightHandle, false);
                    break;

                case PinAlignment.BottomLeft:
                    SetActive(TopLeftHandle, false);
                    SetActive(TopRightHandle, true);
                    break;

                case PinAlignment.BottomRight:
                    SetActive(TopLeftHandle, true);
                    SetActive(TopRightHandle, false);
                    break;
            }
        }
Exemple #6
0
 public PinPoint(double x, double y, PinAlignment alignment)
 {
     this.x         = x;
     this.y         = y;
     this.alignment = alignment;
 }