protected void Update()
    {
        if (IsActive())
        {
            // Retrieve selection result
            VRSelection selection = m_Wand.GetSelection();

            if (selection == null || !selection.SelectedObject.GetComponent <VRActor>().Grabable)
            {
                return;
            }

            m_CurrentSelectedObject = selection.SelectedObject;

            // Manipulation
            if (m_it.HasManipulationStarted())
            {
                // Try to grab
                Grab(m_CurrentSelectedObject);
            }
            else if (m_it.IsManipulationRunning() && m_CurrentManipulatedObject != null)
            {
                // Nothing to do here
            }
            else if (m_it.IsManipulationStopped())
            {
                Ungrab();
            }
        }
    }
Esempio n. 2
0
    void Update()
    {
        if (IsActive())
        {
            // Retrieve selection result
            VRSelection selection = m_Wand.GetSelection();

            if (selection == null || !selection.SelectedObject.GetComponent <VRActor>().Grabable)
            {
                return;
            }

            m_CurrentSelectedObject = selection.SelectedObject;

            switch (m_State)
            {
            case InteractionState.Inactive:
                if (m_it.IsManipulationStarted())
                {
                    GrabInitialPosition(m_CurrentSelectedObject);
                    Grab(m_CurrentSelectedObject);
                    m_State = InteractionState.Running;
                }
                break;

            case InteractionState.Running:
                if (m_it.IsManipulationStopped())
                {
                    Ungrab();
                    m_State = InteractionState.Inactive;
                }
                break;
            }
        }
    }
    void Update()
    {
        if (IsActive())
        {
            // Retrieve selection result
            VRSelection selection = m_Wand.GetSelection();

            if (selection == null || !selection.SelectedObject.GetComponent <VRActor>().Grabable)
            {
                return;
            }

            m_CurrentSelectedObject = selection.SelectedObject;

            switch (m_State)
            {
            case InteractionState.Inactive:
                if (m_it.IsManipulationStarted())
                {
                    GrabInitialPosition(m_CurrentSelectedObject);
                    var authorityRequest = RequestAssignClientAuthority(m_CurrentSelectedObject);
                    if (authorityRequest == AuthorityRequestState.Accepted)
                    {
                        Grab(m_CurrentSelectedObject);
                        m_State = InteractionState.Running;
                    }
                    else
                    {
                        m_State = InteractionState.AuthorityPending;
                    }
                }
                break;

            case InteractionState.AuthorityPending:
                if (m_it.IsManipulationStopped())
                {
                    ClearClientAuthorityRequest();
                    m_State = InteractionState.Inactive;
                }
                else
                {
                    var authorityRequest = RequestAssignClientAuthority(m_CurrentSelectedObject);
                    if (authorityRequest == AuthorityRequestState.Accepted)
                    {
                        Grab(m_CurrentSelectedObject);
                        m_State = InteractionState.Running;
                    }
                }
                break;

            case InteractionState.Running:
                if (m_it.IsManipulationStopped())
                {
                    RequestRemoveClientAuthority(m_CurrentSelectedObject);
                    Ungrab();
                    ClearClientAuthorityRequest();
                    m_State = InteractionState.Inactive;
                }
                break;

            case InteractionState.AuthorityDenied:
                if (m_it.IsManipulationStopped())
                {
                    ClearClientAuthorityRequest();
                    m_State = InteractionState.Inactive;
                }
                break;
            }
        }
    }