Exemple #1
0
        public bool SetHoverState(ProximityController controller, HoverState newHoverState)
        {
            if (newHoverState == HoverState.Hovered || newHoverState == HoverState.None)
            {
                Debug.LogError("Use AddHover or RemoveHover for setting hover state");
                // DSL: Might just want to re-route
                return(false);
            }

            // HoverState.Pressed or HoverState.DraggedAway
            if (newHoverState == HoverState.Pressed)
            {
                if (hoverState != HoverState.Hovered && hoverState != HoverState.DraggedAway)
                {
                    Debug.LogError("Cannot move to Pressed state from " + hoverState);
                    // DSL: Might just want to re-route
                    return(false);
                }
                if (!controller.SortedHoveredObjectsContains(this))
                {
                    controller.AddHoveredItem(this);
                }
                if (!hoveredList.Contains(controller))
                {
                    hoveredList.Add(controller);
                }
            }
            else if (newHoverState == HoverState.DraggedAway)
            {
                if (hoverState != HoverState.Pressed)
                {
                    Debug.LogError("Cannot move to DraggedAway state from " + hoverState);
                    // DSL: Might just want to re-route
                    return(false);
                }
                if (controller.SortedHoveredObjectsContains(this))
                {
                    controller.RemoveHoveredItem(this);
                }
                hoveredList.Remove(controller);
            }

            List <ProximityController> controllerList = new List <ProximityController>()
            {
                controller
            };

            ApplyHoverState(newHoverState, true, controllerList);
            hoverState = newHoverState;

            return(true);
        }
Exemple #2
0
//
//		if (driver.DriverOperationIdle (0) || driver.DriverOperationStarted(0)) {
//			// If in the unpressed state, add hover if available, remove old hover if needed
//			if (hoveredInteractableUi != null) {
//				if (hoveredInteractableUi.hoverState == HoverState.None) {
//					hoveredInteractableUi.AddHover (this);
//				}
//			} else if (driver.DriverOperationStarted(0)) {
//				// No hover, and no selected object, but button tapped
//				uiLaser.ClearUiSelection();
//			}
//
//			if (lastClosestHitObject != hoveredSelectable) {
//				if (previousClosestInteractableUi != null) {
//					previousClosestInteractableUi.RemoveHover (this);
//				}
//			}
//
//		} else {
//			// Controller is in pressed or exiting state. Only process if pressed with downed object
//			if (downedInteractable != null) {
//				if (downedInteractable == hoveredInteractableUi) {
//					// We are on the downed ui object. We need to check the hover state
//					if (downedInteractable.hoverState == HoverState.DraggedAway) {
//						downedInteractable.SetHoverState (this, HoverState.Pressed);
//					}
//				} else {
//					if (downedInteractable.hoverState == HoverState.Pressed) {
//						downedInteractable.SetHoverState (this, HoverState.DraggedAway);
//					}
//				}
//			}
//		}



        public void TriggerExit(ProximityController controller)
        {
            if (controller.downedInteractable == this)
            {
                if (hoverState == HoverState.Pressed)
                {
                    SetHoverState(controller, HoverState.DraggedAway);
                }
            }

                        #if UNITY_EDITOR
            if (debugHover)
            {
                Debug.Log(name + ": trigger exit: " + controller.name + " -- " + controller.SortedHoveredObjectsContains(this));
            }
                        #endif
            if (controller.SortedHoveredObjectsContains(this))
            {
                RemoveHover(controller);
            }
        }
Exemple #3
0
        public void TriggerEnter(ProximityController controller)
        {
            if (controller.downedInteractable == this)
            {
                if (hoverState == HoverState.DraggedAway)
                {
                    SetHoverState(controller, HoverState.Pressed);
                }
            }

            if (!controller.SortedHoveredObjectsContains(this))
            {
                AddHover(controller);
            }
        }