캐릭터 로드
This commit is contained in:
@@ -139,22 +139,10 @@ bool HitTest(out RaycastHit hit)
|
||||
{
|
||||
hit = default;
|
||||
if (hitTestCamera == null) return false;
|
||||
if (!Win32.GetCursorPos(out var pt)) return false;
|
||||
if (!Win32.GetWindowRect(window.Hwnd, out var rc)) return false;
|
||||
// 좌표 변환은 DesktopCursor 에 모아뒀다. 시선 추적도 같은 변환을 쓴다.
|
||||
if (!DesktopCursor.TryGetScreenPosition(window.Hwnd, out Vector2 sp)) return false;
|
||||
|
||||
int w = rc.Width, h = rc.Height;
|
||||
if (w <= 0 || h <= 0) return false;
|
||||
|
||||
// 창 기준 좌표 (좌상단 원점, Y 아래로)
|
||||
int localX = pt.x - rc.left;
|
||||
int localY = pt.y - rc.top;
|
||||
if (localX < 0 || localY < 0 || localX >= w || localY >= h) return false;
|
||||
|
||||
// Unity 화면 좌표 (좌하단 원점, Y 위로)
|
||||
float ux = localX * (Screen.width / (float)w);
|
||||
float uy = (h - localY) * (Screen.height / (float)h);
|
||||
|
||||
var ray = hitTestCamera.ScreenPointToRay(new Vector3(ux, uy, 0f));
|
||||
var ray = hitTestCamera.ScreenPointToRay(new Vector3(sp.x, sp.y, 0f));
|
||||
return Physics.Raycast(ray, out hit, maxRayDistance, interactableLayers);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user