protected override bool ProcessInteractionObject(Interactable interactable, ProcessState processState)
        {
            if (interactable.GetComponent <InteractableUi>() != null && uiLaser != null)
            {
                                #if UNITY_EDITOR
                if (debugInteractor)
                {
                    Debug.Log(name + ": Check selected UI operation: " + 0 + " for state: " + processState);
                }
                                #endif

                InteractionEventData eventData = new InteractionEventData()
                {
                    controller = this
                };

                bool operationStateChanged = false;
                if (DriverOperationStarted(0))
                {
                    eventData.operationId = 0;

                    downedInteractable = interactable;

                    uiLaser.PassButtonDown(interactable);

                    operationStateChanged = true;
                }

                if (DriverOperationEnded(0))
                {
                    eventData.operationId = 0;

                    downedInteractable = null;

                    uiLaser.PassButtonUp(interactable, clickTolerance);

                    interactable.RemovePressedState(this);

                    SurfaceTopHoveredObject();

                    operationStateChanged = true;
                }

                if (!operationStateChanged)
                {
                    // Held
                    eventData.operationId = 0;
                }
            }
            else
            {
                return(base.ProcessInteractionObject(interactable, processState));
            }
            return(true);
        }
Exemple #2
0
        protected virtual bool ProcessInteractionObject(Interactable interactable, ProcessState processState)
        {
            if (interactable != null)
            {
                // Store downed interactable here
                InteractionEventData eventData = new InteractionEventData()
                {
                    controller          = this,
                    hoveredInteractable = interactable,
                    downedInteractable  = downedInteractable
                };

                for (int i = 0; i < (int)InteractionType.Max; i++)
                {
#if UNITY_EDITOR
                    if (debugInteractor)
                    {
                        Debug.Log(Time.frameCount + ": " + name + ": Check operation: " + i + " for state: " + processState);
                    }
#endif

                    bool operationStateChanged = false;
                    if (DriverOperationStarted(i))
                    {
                        eventData.operationId = i;

                        downedInteractable = interactable;
                        downedDistance     = (interactable.transform.position - transform.position).magnitude;

                        if (interactable.OnInteractionDown != null)
                        {
                            interactable.OnInteractionDown(eventData);
                        }

                        interactable.CheckHoverState(new List <ProximityController>()
                        {
                            this
                        });

                        operationStateChanged = true;
                    }

                    if (DriverOperationEnded(i))
                    {
                        eventData.operationId = i;

                        downedInteractable = null;

                        if (DriverOperationClicked(i))
                        {
                            if (interactable.OnInteractionClick != null)
                            {
                                interactable.OnInteractionClick(eventData);
                            }
                        }

                        if (interactable.OnInteractionUp != null)
                        {
                            interactable.OnInteractionUp(eventData);
                        }

                        interactable.CheckHoverState(new List <ProximityController>()
                        {
                            this
                        });

                        operationStateChanged = true;
                    }

                    if (!operationStateChanged)
                    {
                        eventData.operationId = i;

                        if (interactable.OnInteractionContinue != null)
                        {
                            interactable.OnInteractionContinue(eventData);
                        }
                    }
                }
            }
            return(true);
        }