Skip to content

Commit

Permalink
allow smaller than view map to move outside of clamp using padding
Browse files Browse the repository at this point in the history
  • Loading branch information
sambaas committed Feb 7, 2024
1 parent 5ed4c8b commit bf03d81
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Runtime/Scripts/WMTSMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,12 @@ public void Clamp()
var maxPositionXInUnits = -(boundsInMeters.x / startMeterInPixels) * transform.localScale.x;
var maxPositionYInUnits = (boundsInMeters.y / startMeterInPixels) * transform.localScale.x;

var XPadding = rectTransformMinimapUI.sizeDelta.x*0.5f;
var YPadding = rectTransformMinimapUI.sizeDelta.y*0.5f;

this.transform.localPosition = new Vector3(
Mathf.Clamp(this.transform.localPosition.x, maxPositionXInUnits + rectTransformMinimapUI.sizeDelta.x, 0),
Mathf.Clamp(this.transform.localPosition.y, rectTransformMinimapUI.sizeDelta.y, maxPositionYInUnits),
Mathf.Clamp(this.transform.localPosition.x, maxPositionXInUnits + rectTransformMinimapUI.sizeDelta.x - XPadding, XPadding),
Mathf.Clamp(this.transform.localPosition.y, rectTransformMinimapUI.sizeDelta.y - YPadding, maxPositionYInUnits + YPadding),
0
);
}
Expand Down

0 comments on commit bf03d81

Please sign in to comment.