Exemplo n.º 1
0
    /// <summary>
    /// Updates the popup position
    /// </summary>
    private void UpdatePopupPosition()
    {
        // If no marker is selected then exit.
        if (targetMarker == null)
        {
            return;
        }

        var selectedMarker = targetMarker.getDimension() == MapPoint.THREE_DIMENSION
                ? targetMarker.getMarker3D() as OnlineMapsMarkerBase
                : targetMarker.getMarker2D();

        // PABLO - REVISAR
        var isGroupPoints = false;

        if (targetMarker.getGridCluster() != null)
        {
            isGroupPoints = targetMarker.getGridCluster().isGroupPoints();
        }
        // Hide the popup if the marker is outside the map view
        if (!selectedMarker.inMapView)
        {
            if (selectedPopup.activeSelf)
            {
                selectedPopup.SetActive(false);
                return;
            }
        }
        else if (!selectedPopup.activeSelf)
        {
            selectedPopup.SetActive(true);
        }

        // Convert the coordinates of the marker to the screen position.
        Vector2 screenPosition = OnlineMapsControlBase.instance.GetScreenPosition(selectedMarker.position);

        if (Vector2.Distance(prevPosition, screenPosition) > 1f)
        {
            prevPosition = screenPosition;
        }
        else
        {
            prevPosition = screenPosition;
            return;
        }
        //Debug.Log(screenPosition);
        // Add marker height
        //screenPosition.y += selectedMarker.height;

        // Get a local position inside the canvas.
        Vector2 point;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, screenPosition, null, out point);

        // Set local position of the popup
        (selectedPopup.transform as RectTransform).localPosition = point;
    }
Exemplo n.º 2
0
    public void UpdateSpritePosition()
    {
        if (this == null)
        {
            return;
        }
        var position = OnlineMapsTileSetControl.instance.GetWorldPosition(mapPointMarker.getVector2());

        _rectTransform.localPosition = new Vector3(position.x, -position.z, 0f);

        if (mapPointMarker.getDimension() == 3)
        {
            _rectTransform.pivot = new Vector2(0.5f, 0.45f);
        }
        else
        {
            _rectTransform.pivot = new Vector2(0.5f, 0.75f);
        }
    }