Esempio n. 1
0
    void OnTriggerEnter(Collider otherCollider)
    {
        // Get the grab trigger
        OVRGrabbable grabbable = otherCollider.GetComponent <OVRGrabbable>() ?? otherCollider.GetComponentInParent <OVRGrabbable>();

        if (grabbable != null)
        {
            // Add the grabbable
            int refCount = 0;
            m_grabCandidates.TryGetValue(grabbable, out refCount);
            m_grabCandidates[grabbable] = refCount + 1;
        }


        LinearDrive slider = otherCollider.GetComponent <LinearDrive>() ?? otherCollider.GetComponentInParent <LinearDrive>();

        if (slider != null)
        {
            slider.OculusHandHoverUpdate(transform, true, false, false);
        }


        EventButton clickable = otherCollider.GetComponent <EventButton>() ?? otherCollider.GetComponentInParent <EventButton>();

        if (clickable != null)
        {
            if (m_clickables.Count > 0 && m_clickables.Peek().IsHovering)
            {
                m_clickables.Peek().OnHandHoverEnd(null);
            }

            m_clickables.Push(clickable);
            clickable.OnHandHoverBegin(null);
        }
    }
Esempio n. 2
0
    void OnTriggerExit(Collider otherCollider)
    {
        EventButton clickable = otherCollider.GetComponent <EventButton>() ?? otherCollider.GetComponentInParent <EventButton>();

        if (clickable != null)
        {
            if (m_clickables.Contains(clickable))
            {
                var newClickables = RemoveItem(m_clickables, clickable);

                if (clickable.IsHovering)
                {
                    clickable.OnHandHoverEnd(null);
                }

                if (newClickables.Count > 0)
                {
                    m_clickables.Peek().OnHandHoverBegin(null);
                }
            }
        }

        LinearDrive slider = otherCollider.GetComponent <LinearDrive>() ?? otherCollider.GetComponentInParent <LinearDrive>();

        if (slider != null)
        {
            slider.OculusHandHoverUpdate(transform, false, true, false);
        }

        OVRGrabbable grabbable = otherCollider.GetComponent <OVRGrabbable>() ?? otherCollider.GetComponentInParent <OVRGrabbable>();

        if (grabbable == null)
        {
            return;
        }

        // Remove the grabbable
        int  refCount = 0;
        bool found    = m_grabCandidates.TryGetValue(grabbable, out refCount);

        if (!found)
        {
            return;
        }

        if (refCount > 1)
        {
            m_grabCandidates[grabbable] = refCount - 1;
        }
        else
        {
            m_grabCandidates.Remove(grabbable);
        }
    }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     blockTweening           = block.GetComponent <BlockTweening>();
     trackAndDisplayProgress = GetComponent <TrackAndDisplayProgress>();
     linearDrive             = GetComponent <LinearDrive>();
 }