Пример #1
0
 void ProcessMousePress( PointerInputModule.MouseButtonEventData data )
 {
     var buttonData = data.buttonData;
     var gameObject = buttonData.pointerCurrentRaycast.gameObject;
     if (data.PressedThisFrame())
     {
         buttonData.eligibleForClick = true;
         buttonData.delta = Vector2.zero;
         buttonData.dragging = false;
         buttonData.useDragThreshold = true;
         buttonData.pressPosition = buttonData.position;
         buttonData.pointerPressRaycast = buttonData.pointerCurrentRaycast;
         DeselectIfSelectionChanged( gameObject, buttonData );
         var gameObject2 = ExecuteEvents.ExecuteHierarchy<IPointerDownHandler>( gameObject, buttonData, ExecuteEvents.pointerDownHandler );
         if (gameObject2 == null)
         {
             gameObject2 = ExecuteEvents.GetEventHandler<IPointerClickHandler>( gameObject );
         }
         var unscaledTime = Time.unscaledTime;
         if (gameObject2 == buttonData.lastPress)
         {
             var num = unscaledTime - buttonData.clickTime;
             if (num < 0.3f)
             {
                 buttonData.clickCount++;
             }
             else
             {
                 buttonData.clickCount = 1;
             }
             buttonData.clickTime = unscaledTime;
         }
         else
         {
             buttonData.clickCount = 1;
         }
         buttonData.pointerPress = gameObject2;
         buttonData.rawPointerPress = gameObject;
         buttonData.clickTime = unscaledTime;
         buttonData.pointerDrag = ExecuteEvents.GetEventHandler<IDragHandler>( gameObject );
         if (buttonData.pointerDrag != null)
         {
             ExecuteEvents.Execute<IInitializePotentialDragHandler>( buttonData.pointerDrag, buttonData, ExecuteEvents.initializePotentialDrag );
         }
     }
     if (data.ReleasedThisFrame())
     {
         ExecuteEvents.Execute<IPointerUpHandler>( buttonData.pointerPress, buttonData, ExecuteEvents.pointerUpHandler );
         var eventHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>( gameObject );
         if (buttonData.pointerPress == eventHandler && buttonData.eligibleForClick)
         {
             ExecuteEvents.Execute<IPointerClickHandler>( buttonData.pointerPress, buttonData, ExecuteEvents.pointerClickHandler );
         }
         else
         {
             if (buttonData.pointerDrag != null)
             {
                 ExecuteEvents.ExecuteHierarchy<IDropHandler>( gameObject, buttonData, ExecuteEvents.dropHandler );
             }
         }
         buttonData.eligibleForClick = false;
         buttonData.pointerPress = null;
         buttonData.rawPointerPress = null;
         if (buttonData.pointerDrag != null && buttonData.dragging)
         {
             ExecuteEvents.Execute<IEndDragHandler>( buttonData.pointerDrag, buttonData, ExecuteEvents.endDragHandler );
         }
         buttonData.dragging = false;
         buttonData.pointerDrag = null;
         if (gameObject != buttonData.pointerEnter)
         {
             HandlePointerExitAndEnter( buttonData, null );
             HandlePointerExitAndEnter( buttonData, gameObject );
         }
     }
 }
 protected void ProcessMousePress(PointerInputModule.MouseButtonEventData data)
 {
   PointerEventData currentPointerData = data.buttonData;
   GameObject gameObject1 = currentPointerData.pointerCurrentRaycast.gameObject;
   if (data.PressedThisFrame())
   {
     currentPointerData.eligibleForClick = true;
     currentPointerData.delta = Vector2.zero;
     currentPointerData.dragging = false;
     currentPointerData.useDragThreshold = true;
     currentPointerData.pressPosition = currentPointerData.position;
     currentPointerData.pointerPressRaycast = currentPointerData.pointerCurrentRaycast;
     this.DeselectIfSelectionChanged(gameObject1, (BaseEventData) currentPointerData);
     GameObject gameObject2 = ExecuteEvents.ExecuteHierarchy<IPointerDownHandler>(gameObject1, (BaseEventData) currentPointerData, ExecuteEvents.pointerDownHandler);
     if ((UnityEngine.Object) gameObject2 == (UnityEngine.Object) null)
       gameObject2 = ExecuteEvents.GetEventHandler<IPointerClickHandler>(gameObject1);
     float unscaledTime = Time.unscaledTime;
     if ((UnityEngine.Object) gameObject2 == (UnityEngine.Object) currentPointerData.lastPress)
     {
       if ((double) (unscaledTime - currentPointerData.clickTime) < 0.300000011920929)
         ++currentPointerData.clickCount;
       else
         currentPointerData.clickCount = 1;
       currentPointerData.clickTime = unscaledTime;
     }
     else
       currentPointerData.clickCount = 1;
     currentPointerData.pointerPress = gameObject2;
     currentPointerData.rawPointerPress = gameObject1;
     currentPointerData.clickTime = unscaledTime;
     currentPointerData.pointerDrag = ExecuteEvents.GetEventHandler<IDragHandler>(gameObject1);
     if ((UnityEngine.Object) currentPointerData.pointerDrag != (UnityEngine.Object) null)
       ExecuteEvents.Execute<IInitializePotentialDragHandler>(currentPointerData.pointerDrag, (BaseEventData) currentPointerData, ExecuteEvents.initializePotentialDrag);
   }
   if (!data.ReleasedThisFrame())
     return;
   ExecuteEvents.Execute<IPointerUpHandler>(currentPointerData.pointerPress, (BaseEventData) currentPointerData, ExecuteEvents.pointerUpHandler);
   GameObject eventHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(gameObject1);
   if ((UnityEngine.Object) currentPointerData.pointerPress == (UnityEngine.Object) eventHandler && currentPointerData.eligibleForClick)
     ExecuteEvents.Execute<IPointerClickHandler>(currentPointerData.pointerPress, (BaseEventData) currentPointerData, ExecuteEvents.pointerClickHandler);
   else if ((UnityEngine.Object) currentPointerData.pointerDrag != (UnityEngine.Object) null && currentPointerData.dragging)
     ExecuteEvents.ExecuteHierarchy<IDropHandler>(gameObject1, (BaseEventData) currentPointerData, ExecuteEvents.dropHandler);
   currentPointerData.eligibleForClick = false;
   currentPointerData.pointerPress = (GameObject) null;
   currentPointerData.rawPointerPress = (GameObject) null;
   if ((UnityEngine.Object) currentPointerData.pointerDrag != (UnityEngine.Object) null && currentPointerData.dragging)
     ExecuteEvents.Execute<IEndDragHandler>(currentPointerData.pointerDrag, (BaseEventData) currentPointerData, ExecuteEvents.endDragHandler);
   currentPointerData.dragging = false;
   currentPointerData.pointerDrag = (GameObject) null;
   if (!((UnityEngine.Object) gameObject1 != (UnityEngine.Object) currentPointerData.pointerEnter))
     return;
   this.HandlePointerExitAndEnter(currentPointerData, (GameObject) null);
   this.HandlePointerExitAndEnter(currentPointerData, gameObject1);
 }