PressedThisFrame() public method

Was the button pressed this frame?

public PressedThisFrame ( ) : bool
return bool
 private void FakeTouches()
 {
     PointerInputModule.MouseButtonEventData eventData = this.GetMousePointerEventData(0).GetButtonState(PointerEventData.InputButton.Left).eventData;
     if (eventData.PressedThisFrame())
     {
         eventData.buttonData.delta = Vector2.zero;
     }
     this.ProcessTouchPress(eventData.buttonData, eventData.PressedThisFrame(), eventData.ReleasedThisFrame());
     if (base.input.GetMouseButton(0))
     {
         this.ProcessMove(eventData.buttonData);
         this.ProcessDrag(eventData.buttonData);
     }
 }
 static public int PressedThisFrame(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.EventSystems.PointerInputModule.MouseButtonEventData self = (UnityEngine.EventSystems.PointerInputModule.MouseButtonEventData)checkSelf(l);
         var ret = self.PressedThisFrame();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Esempio n. 3
0
 static public int PressedThisFrame(IntPtr l)
 {
     try {
         UnityEngine.EventSystems.PointerInputModule.MouseButtonEventData self = (UnityEngine.EventSystems.PointerInputModule.MouseButtonEventData)checkSelf(l);
         var ret = self.PressedThisFrame();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 4
0
 static public int PressedThisFrame(IntPtr l)
 {
     try{
         UnityEngine.EventSystems.PointerInputModule.MouseButtonEventData self = (UnityEngine.EventSystems.PointerInputModule.MouseButtonEventData)checkSelf(l);
         System.Boolean ret = self.PressedThisFrame();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Esempio n. 5
0
        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);
        }
        protected void ProcessMousePress(PointerInputModule.MouseButtonEventData data)
        {
            PointerEventData buttonData = data.buttonData;
            GameObject       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;
                base.DeselectIfSelectionChanged(gameObject, buttonData);
                GameObject eventHandler = ExecuteEvents.ExecuteHierarchy <IPointerDownHandler>(gameObject, buttonData, ExecuteEvents.pointerDownHandler);
                if (eventHandler == null)
                {
                    eventHandler = ExecuteEvents.GetEventHandler <IPointerClickHandler>(gameObject);
                }
                float unscaledTime = Time.unscaledTime;
                if (eventHandler == buttonData.lastPress)
                {
                    float num2 = unscaledTime - buttonData.clickTime;
                    if (num2 < 0.3f)
                    {
                        buttonData.clickCount++;
                    }
                    else
                    {
                        buttonData.clickCount = 1;
                    }
                    buttonData.clickTime = unscaledTime;
                }
                else
                {
                    buttonData.clickCount = 1;
                }
                buttonData.pointerPress    = eventHandler;
                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);
                GameObject obj4 = ExecuteEvents.GetEventHandler <IPointerClickHandler>(gameObject);
                if ((buttonData.pointerPress == obj4) && buttonData.eligibleForClick)
                {
                    ExecuteEvents.Execute <IPointerClickHandler>(buttonData.pointerPress, buttonData, ExecuteEvents.pointerClickHandler);
                }
                else if ((buttonData.pointerDrag != null) && buttonData.dragging)
                {
                    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)
                {
                    base.HandlePointerExitAndEnter(buttonData, null);
                    base.HandlePointerExitAndEnter(buttonData, gameObject);
                }
            }
        }
        protected void ProcessMousePress(PointerInputModule.MouseButtonEventData data)
        {                                                                              /*	called in ProcessMouseEvent
                                                                                        *
                                                                                        *     sets pointerPress
                                                                                        *             pointerDrag
                                                                                        *             rawPointerPress
                                                                                        *
                                                                                        *     on press this frame
                                                                                        *             call OnPointerDown
                                                                                        *             call OnInitializePotentialDrag
                                                                                        *     on release this frame
                                                                                        *             call OnPointerUp
                                                                                        *             call OnPointerClick
                                                                                        *             call OnDrop
                                                                                        *             call OnEndDrag
                                                                                        */
            PointerEventData buttonData = data.buttonData;
            GameObject       gameObject = buttonData.pointerCurrentRaycast.gameObject; /*hit object. selected*/

            if (data.PressedThisFrame())
            {
                buttonData.eligibleForClick    = true;
                buttonData.delta               = Vector2.zero;
                buttonData.dragging            = false;
                buttonData.useDragThreshold    = true;
                buttonData.pressPosition       = buttonData.position;
                buttonData.pointerPressRaycast = buttonData.pointerCurrentRaycast;
                base.DeselectIfSelectionChanged(gameObject, buttonData);
                GameObject gameObject2 = ExecuteEvents.ExecuteHierarchy <IPointerDownHandler>(gameObject, buttonData, ExecuteEvents.pointerDownHandler); /*pressed obj*/
                if (gameObject2 == null)                                                                                                                 /*if none turns out to handle OnPointerDown*/
                {
                    gameObject2 = ExecuteEvents.GetEventHandler <IPointerClickHandler>(gameObject);
                }
                float unscaledTime = Time.unscaledTime;
                if (gameObject2 == buttonData.lastPress)
                {                /*	if gameObject2 is the lastly pressed object
                                  *     and if the pressed is registered within .3 secs after the prev one, increment clickCount
                                  *     else clickCount = 1
                                  */
                    float 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);
                GameObject eventHandler = ExecuteEvents.GetEventHandler <IPointerClickHandler>(gameObject);
                if (buttonData.pointerPress == eventHandler && buttonData.eligibleForClick)
                {
                    ExecuteEvents.Execute <IPointerClickHandler>(buttonData.pointerPress, buttonData, ExecuteEvents.pointerClickHandler);
                }
                else if (buttonData.pointerDrag != null && buttonData.dragging)
                {
                    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)
                {
                    base.HandlePointerExitAndEnter(buttonData, null);
                    base.HandlePointerExitAndEnter(buttonData, gameObject);
                }
            }
        }