1
This commit is contained in:
@@ -8,13 +8,29 @@ namespace BITKit.UX
|
||||
public class UXScreenJoyStick : UXDrag
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
public float range;
|
||||
public bool resetOnUp;
|
||||
public bool updateDelta;
|
||||
[SerializeField] private float range;
|
||||
[SerializeField] private bool resetOnUp;
|
||||
[SerializeField] private bool updateDelta;
|
||||
[SerializeField] private bool raw;
|
||||
[Header(Constant.Header.Events)]
|
||||
public UnityEvent<Vector2> onDelta;
|
||||
[SerializeField] private UnityEvent<Vector2> onDelta;
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
public Vector2 delta;
|
||||
[SerializeField,ReadOnly] private Vector2 delta;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
visualElement.RegisterCallback<PointerMoveEvent>(OnPointerMove);
|
||||
}
|
||||
|
||||
private void OnPointerMove(PointerMoveEvent evt)
|
||||
{
|
||||
if (raw&& isDraging)
|
||||
{
|
||||
onDelta.Invoke(evt.deltaPosition);
|
||||
}
|
||||
}
|
||||
|
||||
protected override Vector2 GetProcessDelta(Vector2 delta)
|
||||
{
|
||||
delta = Vector2.ClampMagnitude(delta, range);
|
||||
|
Reference in New Issue
Block a user