コード例 #1
0
    public void HandleInputBegin(Vector3 screenPosition)
    {
        var        ray = Camera.main.ScreenPointToRay(screenPosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Interactive"))
            {
                dragDepth  = CameraPlane.CameraToPointDepth(Camera.main, hit.point);
                jointTrans = AttachJoint(hit.rigidbody, hit.point);
            }
        }
    }
コード例 #2
0
    public void HandleInputBegin(Vector3 screenPosition, int touchIndex)
    {
        var        ray = Camera.main.ScreenPointToRay(screenPosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
//			if (hit.transform.gameObject.layer == LayerMask.NameToLayer ("Interactive")) {
            dragDepth = CameraPlane.CameraToPointDepth(Camera.main, hit.point);
            Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPosition);
            jointTrans[touchIndex] = AttachJoint(hit.rigidbody, worldPos);
            Vector3 targetPos = CameraPlane.ScreenToWorldPlanePoint(Camera.main, dragDepth, screenPosition);
            Debug.LogFormat("targetPos = {0} ; worldPos = {1}", targetPos, worldPos);
//			}
        }
    }
コード例 #3
0
    public void HandleInputBegin(Vector3 screenPosition, int touchIndex)
    {
        var        ray = Camera.main.ScreenPointToRay(screenPosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            dragDepth = CameraPlane.CameraToPointDepth(Camera.main, hit.point);
            if (hit.rigidbody != null)
            {
                jointTrans[touchIndex] = AttachJoint(hit.rigidbody, hit.point);
            }
            else if (hit.transform.GetComponent <Rigidbody2D>() != null)
            {
                jointTrans[touchIndex] = AttachJoint(hit.transform.GetComponent <Rigidbody2D>(), hit.point);
            }
        }
    }