public void RemoveHover(ProximityController controller) { #if UNITY_EDITOR if (debugHover) { Debug.Log(name + ": Remove hover: " + controller.name); } #endif List <ProximityController> controllerList = new List <ProximityController>() { controller }; // If there is a controller and it holds this object: int numRemaining = controller.RemoveHoveredItem(this); hoveredList.Remove(controller); CheckHoverState(controllerList); if (numRemaining > 0) { // turn on other hovered object Interactable other = controller.GetTopHoveredItem(); if (other != null) { if (other.GetComponent <Interactable> () != null) { other.GetComponent <Interactable> ().CheckHoverState(controllerList); } } } }
public bool AddHover(ProximityController controller) { if (!this.enabled) { return(false); } List <ProximityController> controllerList = new List <ProximityController>() { controller }; #if UNITY_EDITOR if (debugHover) { if (controller.gameObject == gameObject) { Debug.LogError("Double hover on gameObject " + controller.name); } } #endif // // if (!CanBeHovered (controller)) { // #if UNITY_EDITOR // if (debugHover) // { // Debug.Log("Can't be hovered: " + this.name); // } // #endif // // return false; // } // if (hoveredList.Contains(controller)) { #if UNITY_EDITOR if (debugHover) { Debug.Log("Hover Stay: " + this.name); } #endif // CheckHoverState(controllerList); // this passes down the hover stay command return(false); } #if UNITY_EDITOR if (debugHover) { Debug.Log("Adding Hovered controller: " + controller.name); } #endif hoveredList.Add(controller); Interactable other = null; if (controller.GetHoverCount() > 0) { // There's another hovered object, grab handle for it to exit the hover state other = controller.GetTopHoveredItem(); } #if UNITY_EDITOR if (debugHover) { Debug.Log("Adding Hovered item: " + this.name); } #endif controller.AddHoveredItem(this); #if UNITY_EDITOR if (debugHover) { Debug.Log("Checking hover state: " + this.name); } #endif CheckHoverState(controllerList); if (other != null) { if (other.GetComponent <Interactable> () != null) { other.GetComponent <Interactable> ().CheckHoverState(controllerList); } } return(true); }