unity - Input Mouse Position 입력 마우스 위치





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class TestMousePoint : MonoBehaviour
{
    [SerializeField] float m_RayDepth = -10;
 
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButton("Fire1"))
        {
            Vector3 screenPos = Camera.main.WorldToScreenPoint(Input.mousePosition);
            //Debug.Log("target is " + screenPos + " pixels from the left");
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
 
            Vector3 pos = ray.origin + ray.direction * m_RayDepth;
            Debug.Log("m_Vertex[0].position : " + pos);
            Debug.DrawRay(Camera.main.transform.position, pos);
        }
    }
}
cs

댓글