채팅 추가
This commit is contained in:
@@ -45,6 +45,7 @@ public class CharacterDragger : MonoBehaviour
|
||||
Transform target;
|
||||
bool pressing; // 버튼이 눌린 상태(아직 드래그는 아닐 수 있음)
|
||||
bool dragging; // 임계값을 넘겨 실제 드래그 중
|
||||
bool prevButtonDown; // 눌린 순간만 잡아내기 위한 직전 프레임 상태
|
||||
Vector2 pressStartPos;
|
||||
Vector2 grabScreenOffset; // 캐릭터 원점 - 커서 (화면 좌표)
|
||||
Vector2 boundsOffMin, boundsOffMax; // 원점 기준 캐릭터의 화면상 범위
|
||||
@@ -56,6 +57,14 @@ public class CharacterDragger : MonoBehaviour
|
||||
/// <summary>드래그가 끝난 순간 호출. 창 올라타기가 착지 지점을 다시 계산할 때 쓴다.</summary>
|
||||
public event System.Action<Transform> DragEnded;
|
||||
|
||||
/// <summary>
|
||||
/// 캐릭터를 끌지 않고 그냥 눌렀다 뗀 순간 호출. 채팅창 토글이 이걸 쓴다.
|
||||
///
|
||||
/// 클릭과 드래그의 구분은 이미 dragThresholdPixels 로 하고 있으므로 판정을
|
||||
/// 새로 만들지 않고 여기에 얹는다. 조금이라도 끌었으면 클릭이 아니다.
|
||||
/// </summary>
|
||||
public event System.Action Clicked;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
hitTest = GetComponent<ClickThroughHitTest>();
|
||||
@@ -74,7 +83,13 @@ void Update()
|
||||
bool buttonDown = mouse != null && mouse.leftButton.isPressed;
|
||||
#endif
|
||||
|
||||
if (!pressing && buttonDown && hitTest.IsOverCharacter)
|
||||
// 눌린 "순간"만 잡는다. 이미 누른 채로 커서가 캐릭터 위로 지나가는 경우
|
||||
// (다른 창을 끌고 오다가 캐릭터를 스치는 등)에 잡히면 안 된다.
|
||||
// 클릭으로 채팅창이 토글되면서부터는 이 오작동이 눈에 띄게 된다.
|
||||
bool justPressed = buttonDown && !prevButtonDown;
|
||||
prevButtonDown = buttonDown;
|
||||
|
||||
if (!pressing && justPressed && hitTest.IsOverCharacter)
|
||||
{
|
||||
BeginPress();
|
||||
}
|
||||
@@ -152,6 +167,7 @@ void EndPress()
|
||||
target = null;
|
||||
|
||||
if (wasDragging && dragged != null) DragEnded?.Invoke(dragged);
|
||||
else if (!wasDragging && dragged != null) Clicked?.Invoke();
|
||||
}
|
||||
|
||||
bool TryGetCursor(out Vector2 screenPos)
|
||||
|
||||
Reference in New Issue
Block a user