protected override bool DisableHoverClick(TransformEventData data)
        {
            if (!enableFistHover)
            {
                return(false);
            }

      #if !CP_ORION
            LeapMotionEventData ldata = data as LeapMotionEventData;
            if (ldata == null)
            {
                return(false);
            }
            float radius = ldata.hand.GetLeapHand().SphereRadius;
            //Debug.Log("fist radius " + radius);
            bool hasFist = radius < 40f;
            if (hasFist && !ldata.hadFist)
            {
                print("reseting time for fist");
                // Reset the time since entered.
                ldata.timeSinceEntered = Time.unscaledTime;
            }
            if (!hasFist && ldata.hadFist)
            {
                ldata.SetProgress(0f);
                ldata.timeSinceEntered = Time.unscaledTime;
            }
            ldata.hadFist = hasFist;
            return(!hasFist);
      #else
            return(false);
      #endif
        }
 /* We should activate if we're enabled, there's a pointer of ours in
  * the scene, and it's moved recently. */
 public override bool ShouldActivateModule()
 {
     if (!enabled)
     {
         return(false);
     }
     // If we moved recently, then we should probably activate.
     foreach (PointerEventData eventData in m_PointerData.Values)
     {
         TransformEventData eventDataP = (TransformEventData)eventData;
         Transform          pointer    = eventDataP.pointer;
         if (pointer != null &&
             !Mathf.Approximately((pointer.position - eventDataP.lastPosition).magnitude, 0f))
         {
             eventDataP.lastPosition   = pointer.position;
             eventDataP.timeSinceMoved = Time.unscaledTime;
         }
         if (pointer != null &&
             (Time.unscaledTime - eventDataP.timeSinceMoved) < timeToDeactivate)
         {
             return(true);
         }
     }
     return(false);
 }
 /* The open source code says this is protected but with Unity 4.6.1,
  * it's not callable from an inherited. Returns true if created,
  * false otherwise.*/
 protected new bool GetPointerData(int id, out PointerEventData data, bool create)
 {
     if (!m_PointerData.TryGetValue(id, out data) && create)
     {
         data = new TransformEventData(eventSystem)
         {
             pointerId = id,
         };
         m_PointerData.Add(id, data);
         return(true);
     }
     return(false);
 }
        // Maybe instead of an image, it should be just some object that
        // has the following properties?
        // ProgressIndicator.proportion
        // ProgressIndicator.screenLocation
        // ProgressIndicator.worldLocation

        /*
         * Register a pointer with a particular transform and pointer ID.
         */
        public void RegisterPointer(int id, Transform pointer, Image progressBar)
        {
            print("register pointer id " + id);
            PointerEventData eventData;
            bool             newData = GetPointerData(id, out eventData, true);

            newData |= true; // XXX avoid the warning that newData is never used.
            TransformEventData eData = (TransformEventData)eventData;

            //print("set pointer");
            eData.pointer = pointer;
            //print("set pointer " + eData.pointer);
            eData.progressBar = progressBar;
            // pointer = t;
            // pointerId = id;
            // lastPosition = pointer.position;
        }
        /*
         * Process UI input event using the screen coordinates of the
         * pointer's position.
         */
        public override void Process()
        {
            foreach (int pointerId in m_PointerData.Keys)
            {
                PointerEventData eventData;
                bool             newData = GetPointerData(pointerId, out eventData, false);
                newData &= true; // XXX remove warning
                TransformEventData eData = (TransformEventData)eventData;
                // We only process if we have a pointer.
                if (eData.pointer == null)
                {
                    continue;
                }
                var screenPosition =
                    Camera.main.WorldToScreenPoint(eData.pointer.position);

                Vector2 newPosition = new Vector2(screenPosition.x, screenPosition.y);
                eventData.delta    = newPosition - eventData.position;
                eventData.position = newPosition;
                //eventData.pointerPress = null;

                eventSystem.RaycastAll(eventData, m_RaycastResultCache);

                var raycast = FindFirstRaycast(m_RaycastResultCache);
                eventData.pointerCurrentRaycast = raycast;
                m_RaycastResultCache.Clear();
                var currentOverGo = eventData.pointerCurrentRaycast.gameObject;

                if (enableHoverClick && !DisableHoverClick(eData))
                {
                    // If we enter a thing that is clickable, we wait, then draw
                    // the animation.  Once the animation finishes, we click it.
                    if (eventData.pointerEnter == currentOverGo &&
                        eData.timeSinceEntered > eData.timeSinceClicked &&
                        !eventData.dragging &&
                        IsClickable(currentOverGo))
                    {
                        //print("1");
                        // We're hovering over the same item.
                        float enteredDuration = Time.unscaledTime - eData.timeSinceEntered;
                        if (enteredDuration < preProgress)
                        {
                            //print("2");
                            // We don't show the progress immediately; we wait a little while.
                            eData.SetProgress(0f);
                        }
                        else
                        {
                            //print("3");
                            // Let's show the current progress.
                            float progress = (enteredDuration - preProgress) / timeToFill;
                            eData.SetProgress(progress);
                            if (progress >= 1f)
                            {
                                //print("4");
                                // Click.
                                if (enableHoverDrag && IsDraggable(currentOverGo))
                                {
                                    if (!eventData.dragging)
                                    {
                                        // Press down.
                                        ProcessGesturePress(eventData,
                                                            true,
                                                            false);
                                        eventData.dragging = true;
                                    }
                                    else
                                    {
                                        // Release click.
                                        Assert.IsNotNull(eventData);
                                        ProcessGesturePress(eventData,
                                                            false,
                                                            true);
                                    }
                                }
                                else
                                {
                                    ProcessGesturePress(eventData,
                                                        true,
                                                        true);
                                    // This is probably wrong.
                                    eventData.selectedObject = null;
                                }
                                eData.timeSinceClicked = Time.unscaledTime;
                                // Reset.
                                eData.SetProgress(0f);
                                // Whew. These things are hard to manage.

                                //eventData.pointerEnter = null;
                            }
                        }
                    }
                    else if (eventData.pointerEnter != currentOverGo)
                    {
                        if (eventData.dragging &&
                            IsClickable(currentOverGo)
                            // Make sure CurrentOverGo is not the pointerDrag
                            // and that it's not a child of the pointerDrag.
                            && eventData.pointerDrag != currentOverGo &&
                            !currentOverGo.transform.IsChildOf(eventData.pointerDrag.transform))
                        {
                            // Release!
                            ProcessGesturePress(eventData,
                                                false,
                                                true);
                            //print("over other thing and dragging " + currentOverGo);
                            //Debug.Log("Hi", currentOverGo);
                        }
                        //print("5");
                        // We're over something but we don't think it's clickable.
                        eData.SetProgress(0f);
                        eData.timeSinceEntered = Time.unscaledTime;
                    }
                }

                if (shouldClick.Count != 0 &&
                    shouldClick.Contains(eventData.pointerId))
                {
                    ProcessGesturePress(eventData, true, true);
                    ((TransformEventData)eventData).timeSinceClicked = Time.unscaledTime;
                    eData.SetProgress(0f);
                    shouldClick.Remove(eventData.pointerId);
                }
                ProcessMove(eventData);
                if (enableHoverDrag)
                {
                    ProcessDrag(eventData);
                }
            }
        }
 /*
  * If hover click is enabled, this method can disable it temporarily.
  */
 protected virtual bool DisableHoverClick(TransformEventData data)
 {
     return(false);
 }