오류수정
This commit is contained in:
@@ -46,6 +46,7 @@ public class CharacterDragger : MonoBehaviour
|
||||
bool pressing; // 버튼이 눌린 상태(아직 드래그는 아닐 수 있음)
|
||||
bool dragging; // 임계값을 넘겨 실제 드래그 중
|
||||
bool prevButtonDown; // 눌린 순간만 잡아내기 위한 직전 프레임 상태
|
||||
bool prevRightDown;
|
||||
Vector2 pressStartPos;
|
||||
Vector2 grabScreenOffset; // 캐릭터 원점 - 커서 (화면 좌표)
|
||||
Vector2 boundsOffMin, boundsOffMax; // 원점 기준 캐릭터의 화면상 범위
|
||||
@@ -65,6 +66,15 @@ public class CharacterDragger : MonoBehaviour
|
||||
/// </summary>
|
||||
public event System.Action Clicked;
|
||||
|
||||
/// <summary>
|
||||
/// 캐릭터 위에서 오른쪽 버튼을 누른 순간. 포즈 바꾸기 등에 쓴다.
|
||||
///
|
||||
/// 왼쪽 버튼과 같은 방식으로 OS 에 직접 묻는다. 이 창은 포커스를 받지 않아
|
||||
/// Unity 입력을 신뢰하기 어렵고, 무엇보다 판정에 쓰는 커서 좌표를 이미
|
||||
/// GetCursorPos 로 얻고 있어 두 경로를 섞을 이유가 없다.
|
||||
/// </summary>
|
||||
public event System.Action RightClicked;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
hitTest = GetComponent<ClickThroughHitTest>();
|
||||
@@ -78,11 +88,17 @@ void Update()
|
||||
{
|
||||
#if !UNITY_EDITOR && UNITY_STANDALONE_WIN
|
||||
bool buttonDown = Win32.IsKeyDown(Win32.VK_LBUTTON);
|
||||
bool rightDown = Win32.IsKeyDown(Win32.VK_RBUTTON);
|
||||
#else
|
||||
var mouse = UnityEngine.InputSystem.Mouse.current;
|
||||
bool buttonDown = mouse != null && mouse.leftButton.isPressed;
|
||||
bool rightDown = mouse != null && mouse.rightButton.isPressed;
|
||||
#endif
|
||||
|
||||
// 오른쪽 버튼은 누른 순간만 본다. 드래그와 달리 이어지는 조작이 없다.
|
||||
if (rightDown && !prevRightDown && hitTest.IsOverCharacter) RightClicked?.Invoke();
|
||||
prevRightDown = rightDown;
|
||||
|
||||
// 눌린 "순간"만 잡는다. 이미 누른 채로 커서가 캐릭터 위로 지나가는 경우
|
||||
// (다른 창을 끌고 오다가 캐릭터를 스치는 등)에 잡히면 안 된다.
|
||||
// 클릭으로 채팅창이 토글되면서부터는 이 오작동이 눈에 띄게 된다.
|
||||
|
||||
Reference in New Issue
Block a user