Exemplo n.º 1
0
    private void AdjustPanel()
    {
        var screenPos = panel.TransformPoint(0, panel.rect.yMin, 0);
        var mapPos    = mapView.WorldToLocal(screenPos);

        panelPos.y             = -Mathf.Min(0, mapView.Rect.height + mapPos.y - 3 - panel.anchoredPosition.y);
        panel.anchoredPosition = panelPos;
    }
Exemplo n.º 2
0
    private void UpdatePanelPosition()
    {
        Vector3 inputPos = Input.mousePosition;
        Vector2 pos      = inputPos;

        pos.x += paddingRight;
        pos.y -= paddingBottom;

        if (flippedY)
        {
            pos.y -= 40;
        }
        if (flippedX)
        {
            pos.x += 40;
        }

        Vector2 localMousePosition = mapViewArea.WorldToLocal(pos);

        if ((localMousePosition.y - panel.container.rect.height) < mapViewArea.Rect.yMin)
        {
            pos.y    = inputPos.y + paddingTop * scaleFactor + panel.container.rect.height;
            flippedY = true;
        }
        else if (flippedY)
        {
            pos.y   += 40;
            flippedY = false;
        }

        if ((localMousePosition.x + panel.container.rect.width) > mapViewArea.Rect.xMax)
        {
            pos.x    = inputPos.x - paddingLeft * scaleFactor - panel.container.rect.width;
            flippedX = true;
        }
        else if (flippedX)
        {
            pos.x   -= 40;
            flippedX = false;
        }

        panel.transform.position = pos;
    }