Esempio n. 1
0
    public LayerRect(LayerPoint point, float width, float height, WorldAnchor anchor)
    {
        this.point = point;
        this.width = width;
        this.height = height;
        this.anchor = anchor;

        CalcCornerPoints(out TopLeft, out BottomRight);
        Rect = RectTool.Create(TopLeft.InLayerPoint, BottomRight.InLayerPoint);
    }
Esempio n. 2
0
    private void CalcCornerPoints(out LayerPoint topLeft, out LayerPoint bottomRight)
    {
        // anchor to TopLeft
        float topLeftOffsetX = 0;
        float topLeftOffsetY = 0;
        float bottomRightOffsetX = 0;
        float bottomRightOffsetY = 0;

        if (anchor == WorldAnchor.BottomLeft || anchor == WorldAnchor.MiddleLeft || anchor == WorldAnchor.TopLeft)
        {
            topLeftOffsetX = 0;
            bottomRightOffsetX = width;
        }
        if (anchor == WorldAnchor.BottomCenter || anchor == WorldAnchor.MiddleCenter || anchor == WorldAnchor.TopCenter)
        {
            topLeftOffsetX = -width / 2;
            bottomRightOffsetX = width / 2;
        }
        if (anchor == WorldAnchor.BottomRight || anchor == WorldAnchor.MiddleRight || anchor == WorldAnchor.TopRight)
        {
            topLeftOffsetX = -width;
            bottomRightOffsetX = 0;
        }

        if (anchor == WorldAnchor.BottomLeft || anchor == WorldAnchor.BottomCenter || anchor == WorldAnchor.BottomRight)
        {
            topLeftOffsetY = height;
            bottomRightOffsetY = 0;
        }
        if (anchor == WorldAnchor.MiddleLeft || anchor == WorldAnchor.MiddleCenter || anchor == WorldAnchor.MiddleRight)
        {
            topLeftOffsetY = height / 2;
            bottomRightOffsetY = -height / 2;
        }
        if (anchor == WorldAnchor.TopLeft || anchor == WorldAnchor.TopCenter || anchor == WorldAnchor.TopRight)
        {
            topLeftOffsetY = 0;
            bottomRightOffsetY = -height;
        }

        topLeft = new LayerPoint(point, new Vector3(topLeftOffsetX, topLeftOffsetY));
        bottomRight = new LayerPoint(point, new Vector3(bottomRightOffsetX, bottomRightOffsetY));
    }
Esempio n. 3
0
 public Vector3 LayerToScreenPoint(Vector3 position)
 {
     LayerPoint point = new LayerPoint(this, position);
     return point.InScreenPoint;
 }
Esempio n. 4
0
 public LayerPoint(LayerPoint point, Vector2 offset)
 {
     this.layer = point.layer;
     this.layerPoint = point.layerPoint + offset;
 }