Exemplo n.º 1
0
    protected void UpdateBeam()
    {
        VRUIElement targetUI = null;

        Vector3    fwd = transform.TransformDirection(Vector3.forward);
        RaycastHit hitInfo;
        int        layer = LayerMask.GetMask("UI");

        if (Physics.Raycast(transform.position, fwd, out hitInfo, 100.0f, layer))
        {
            Debug.DrawLine(transform.position, hitInfo.point, Color.red);
            targetUI = hitInfo.collider.gameObject.GetComponentInParent <VRUIElement>();

            //Debug.LogError(string.Format("UpdateBeam::Physics.Raycast name({0}), point({1})", hitInfo.collider.gameObject.name, hitInfo.point));
        }
        SetHoverTarget(targetUI);
    }
Exemplo n.º 2
0
    protected void SetHoverTarget(VRUIElement p_uiElement)
    {
        if (m_hoverTarget != p_uiElement)
        {
            if (m_hoverTarget != null)
            {
                Debug.Log("SendMessage OnRayHoverEnd:" + this.gameObject.name);
                m_hoverTarget.SendMessage("OnRayHoverEnd", this, SendMessageOptions.DontRequireReceiver);
            }

            m_hoverTarget = p_uiElement;

            if (m_hoverTarget != null)
            {
                Debug.Log("SendMessage OnRayHoverBegin:" + this.gameObject.name);
                m_hoverTarget.SendMessage("OnRayHoverBegin", this, SendMessageOptions.DontRequireReceiver);
            }
        }
    }