버그 수정
This commit is contained in:
@@ -117,7 +117,7 @@ namespace UVC.UI
|
|||||||
public RectTransform DragArea => dragArea;
|
public RectTransform DragArea => dragArea;
|
||||||
public bool IsDragging { private set; get; }
|
public bool IsDragging { private set; get; }
|
||||||
|
|
||||||
private void Awake()
|
private void Start()
|
||||||
{
|
{
|
||||||
InitializeComponents();
|
InitializeComponents();
|
||||||
ValidateSetup();
|
ValidateSetup();
|
||||||
@@ -250,13 +250,10 @@ namespace UVC.UI
|
|||||||
{
|
{
|
||||||
Vector2 offsetToOriginal = localPointerPosition - originalLocalPointerPosition;
|
Vector2 offsetToOriginal = localPointerPosition - originalLocalPointerPosition;
|
||||||
Vector2 newPosition = originalAnchoredPosition + offsetToOriginal;
|
Vector2 newPosition = originalAnchoredPosition + offsetToOriginal;
|
||||||
|
//Debug.Log($"OnDrag originalAnchoredPosition:{originalAnchoredPosition}, newPosition:{newPosition}");
|
||||||
// 실시간 제약 적용
|
// 실시간 제약 적용
|
||||||
if (constrainDuringDrag)
|
if (constrainDuringDrag) newPosition = ClampToArea(newPosition);
|
||||||
{
|
//Debug.Log($"OnDrag2 newPosition:{newPosition}");
|
||||||
newPosition = ClampToArea(newPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
dragObject.anchoredPosition = newPosition;
|
dragObject.anchoredPosition = newPosition;
|
||||||
OnDragHandler?.Invoke(newPosition);
|
OnDragHandler?.Invoke(newPosition);
|
||||||
}
|
}
|
||||||
@@ -279,10 +276,10 @@ namespace UVC.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 최종 위치 제약 적용
|
// 최종 위치 제약 적용
|
||||||
Vector2 finalPosition = ClampToArea(dragObject.anchoredPosition);
|
//Vector2 finalPosition = ClampToArea(dragObject.anchoredPosition);
|
||||||
dragObject.anchoredPosition = finalPosition;
|
//dragObject.anchoredPosition = finalPosition;
|
||||||
|
|
||||||
OnEndDragHandler?.Invoke(finalPosition);
|
//OnEndDragHandler?.Invoke(finalPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -303,15 +300,18 @@ namespace UVC.UI
|
|||||||
|
|
||||||
Rect dragObjectRect = dragObject.rect;
|
Rect dragObjectRect = dragObject.rect;
|
||||||
Rect dragAreaRect = dragArea.rect;
|
Rect dragAreaRect = dragArea.rect;
|
||||||
|
dragAreaRect.x = 0;
|
||||||
|
dragAreaRect.y = 0;
|
||||||
|
|
||||||
// Pivot과 앵커를 고려한 경계 계산
|
// Pivot과 앵커를 고려한 경계 계산
|
||||||
Vector2 pivot = dragObject.pivot;
|
Vector2 pivot = dragObject.pivot;
|
||||||
Vector2 size = dragObjectRect.size;
|
Vector2 size = dragObjectRect.size;
|
||||||
|
|
||||||
|
//아래로 내려갈수록 좌상(0,0), 우하(1,-1)
|
||||||
float leftBoundary = dragAreaRect.xMin + (size.x * pivot.x) + leftPadding;
|
float leftBoundary = dragAreaRect.xMin + (size.x * pivot.x) + leftPadding;
|
||||||
float rightBoundary = dragAreaRect.xMax - (size.x * (1f - pivot.x)) - rightPadding;
|
float rightBoundary = dragAreaRect.xMax - (size.x * (1f - pivot.x)) - rightPadding;
|
||||||
float bottomBoundary = (size.y * pivot.y) + bottomPadding;
|
float bottomBoundary = -dragAreaRect.height + (size.y * pivot.y) + bottomPadding;
|
||||||
float topBoundary = dragAreaRect.height - (size.y * (1f - pivot.y)) - topPadding;
|
float topBoundary = -(size.y * (1f - pivot.y)) - topPadding;
|
||||||
|
|
||||||
position.x = Mathf.Clamp(position.x, leftBoundary, rightBoundary);
|
position.x = Mathf.Clamp(position.x, leftBoundary, rightBoundary);
|
||||||
position.y = Mathf.Clamp(position.y, bottomBoundary, topBoundary);
|
position.y = Mathf.Clamp(position.y, bottomBoundary, topBoundary);
|
||||||
@@ -351,16 +351,5 @@ namespace UVC.UI
|
|||||||
{
|
{
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
private void OnValidate()
|
|
||||||
{
|
|
||||||
// 에디터에서 값 변경 시 유효성 검사
|
|
||||||
if (Application.isPlaying)
|
|
||||||
{
|
|
||||||
ValidateSetup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user