Example #1
0
	//
	// Private Methods
	//

	private void UpdateOffset()
	{
		var invScaleFactor = 1f / canvas.scaleFactor;

		// Shift the top of the rect to always be below the title bar
		var backgroundOffset = mapViewArea.RectTransform.TransformPoint(0, mapViewArea.Rect.yMax, 0).y - Screen.height;
		var rt = transform as RectTransform;
		var o = rt.offsetMax;
		o.y = backgroundOffset * invScaleFactor;
		rt.offsetMax = o;

		// Adjust the vertical offset of the modal dialogs
		var newOffset = mapViewArea.WorldCenter();
		newOffset.x *= invScaleFactor;
		newOffset.y *= invScaleFactor;

		if (offset.x != newOffset.x || offset.y != newOffset.y)
		{
			offset = newOffset;
			for (int i = 0; i < count; i++)
			{
				var child = transform.GetChild(i);
				if (child != background)
					child.localPosition = offset;
			}
		}
	}
Example #2
0
    private void UpdateMapViewCenter()
    {
        UpdateDistanceToMap();

        needToUpdateBounds   = true;
        needToUpdateViewport = true;

        if (lastPixelHeight != cam.pixelHeight)
        {
            lastPixelHeight  = cam.pixelHeight;
            needToAdjustZoom = true;
        }

        if (mapViewArea != null)
        {
            mapViewCenter = mapViewArea.WorldCenter();
        }
    }