Unity Camera.ScreenToWorldPoint

Unity – Scripting API: Camera.ScreenToWorldPoint (unity3d.com)
Camera 클래스의 ScreenToWorldPoint 함수는 스크린 좌표를 카메라가 찍고있는 3차원의 좌표로 바꿔줌.

void OnGUI()
{
        Vector3 point = new Vector3();
        Event   currentEvent = Event.current;
        Vector3 mousePos = new Vector3();

        // Get the mouse position from Event.
        // Note that the y position from Event is inverted. (GUI space -> Screen space)
        mousePos.x = currentEvent.mousePosition.x;
        mousePos.y = Camera.main.pixelHeight - currentEvent.mousePosition.y;
        mousePos.z = Camera.main.nearClipPlane; 
        point = Camera.main.ScreenToWorldPoint(mousePos);

        GUILayout.BeginArea(new Rect(20, 20, 250, 120));
        GUILayout.Label("Screen pixels: " + cam.pixelWidth + ":" + cam.pixelHeight);
        GUILayout.Label("Mouse position: " + mousePos);
        GUILayout.Label("World position: " + point.ToString("F3"));
        GUILayout.EndArea();
}

Term Project Group

Group1 – 가준영, 여성제, 문유빈

Group2 – 박강, 윤호상, 황인우

Group3 – 박경빈, 이진섭, 정선우

Group4 – 박용희, 배준하, 서준호

Group5 – 송지우, 유연주,  양우성

Group6 – 오세윤, 윤현, 이종민

Group7 – 임찬, 정건우, 주예나, 차선우

Group8 – 박종민, 이시훈