Skip to content

Commit

Permalink
Bugfix offset breaking on new parts
Browse files Browse the repository at this point in the history
  • Loading branch information
rudderbucky committed Jan 8, 2021
1 parent 86230a7 commit 947a8a3
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,15 @@ public void GrabPart(ShipBuilderPart part) {
parts.Add(part);
part.rectTransform.SetAsLastSibling();
}
// offset = Vector2.zero;
offset = part.GetComponent<RectTransform>().anchoredPosition - GetComponent<RectTransform>().anchoredPosition;

// code to ensure part does not snap to cursor immediately
var pos = part.GetComponent<RectTransform>().anchoredPosition;

// if the initial position is zero that means this is a new part, don't set an offset
if(pos == Vector2.zero)
offset = Vector2.zero;
else
offset = pos - GetComponent<RectTransform>().anchoredPosition;
currentPart = part;
}
void PlaceCurrentPart() {
Expand Down

0 comments on commit 947a8a3

Please sign in to comment.