예제 #1
0
    private void MousePick(RaycastHitHandler handler)
    {
        Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            handler(hit);
        }
    }
예제 #2
0
파일: scr.cs 프로젝트: Alan19/ThereminAR
    private void Update()
    {
        RayIndicator.transform.position = _controller.Position;
        RayIndicator.transform.rotation = _controller.Orientation;
        RaycastHit        hit;
        RaycastHitHandler handler = null;

        if (Physics.Raycast(_controller.Position, _controller.Orientation * Vector3.forward, out hit))
        {
            handler = hit.collider.gameObject.GetComponent <RaycastHitHandler>();
        }
        try {
            if (handler != null)
            {
                handler.OnPoint(_controller.TriggerValue > .1f);
                if (!System.Object.ReferenceEquals(lastHovered, handler))
                {
                    if (lastHovered != null)
                    {
                        lastHovered.OnPointLeave(_controller.TriggerValue > .1f);
                    }
                    handler.OnPointEnter(_controller.TriggerValue > .1f);
                }
            }
            else
            {
                if (lastHovered != null)
                {
                    lastHovered.OnPointLeave(_controller.TriggerValue > .1f);
                }
            }
        } catch (System.NotImplementedException e) {
            Debug.LogError(e);
        }

        lastHovered = handler;
    }