Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Add ability to move all control points simultaneously
Browse files Browse the repository at this point in the history
  • Loading branch information
Poyo-SSB committed Jun 16, 2018
1 parent 89da32e commit af44274
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions Assets/Scripts/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ public static class Constants
public const float BASE_TEXT_SIZE = 35f;

public static readonly Color HANDLE_COLOR = Color.yellow;
public static readonly Color MULTIPLE_HANDLE_COLOR = Color.blue;
}
}
12 changes: 10 additions & 2 deletions Assets/Scripts/UI/Handles/Handle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ public class Handle : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler,
public void OnDrag(PointerEventData eventData)
{
// Set the color because the handles lag behind by one frame for some reason which I don't care enough to ascertain.
this.center.color = Constants.HANDLE_COLOR;
this.Bound.Value += new Vector2(eventData.delta.x, -eventData.delta.y) / this.ratio;
if (eventData.button == PointerEventData.InputButton.Left)
{
this.center.color = Constants.HANDLE_COLOR;
this.Bound.Value += new Vector2(eventData.delta.x, -eventData.delta.y) / this.ratio;
}
else if (eventData.button == PointerEventData.InputButton.Right)
{
this.center.color = Constants.MULTIPLE_HANDLE_COLOR;
this.Manager.MoveAll(new Vector2(eventData.delta.x, -eventData.delta.y) / this.ratio);
}
}

public void OnEndDrag(PointerEventData eventData) => this.center.color = Color.white;
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/UI/Handles/HandleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,13 @@ private void Update()
handle.UpdatePosition(this.RectTransform.rect.width / Playfield.WIDTH);
}
}

public void MoveAll(Vector2 delta)
{
foreach (var handle in this.handles)
{
handle.Bound.Value += delta;
}
}
}
}

0 comments on commit af44274

Please sign in to comment.