Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Using IPointerDownHandler and IBeginDragHandler at the same time

Discussion in 'Scripting' started by MegGriffin, Jul 30, 2023.

  1. MegGriffin

    MegGriffin

    Joined:
    Oct 22, 2022
    Posts:
    7
    I am creating a game by UI elements and I have pieces. I want them to rotate when I click them and transform them when I drag them. Both works actually. However, when I drag them, both IPointerDownHandler and IBeginDragHandler methods work and they are rotated even if I am dragging them. How can I make IPointerDownHandler method not to work while I am dragging?
    Thank you
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Normally you would let those methods continue to be called but you would check if you should be paying attention to that particular call and doing anything with the data, or just ignoring it.
     
  3. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    maybe do ipointerup instead? and dont rotate if they have been dragged
     
  4. MegGriffin

    MegGriffin

    Joined:
    Oct 22, 2022
    Posts:
    7
    they are rotating when i am ending dragging this time
     
  5. MegGriffin

    MegGriffin

    Joined:
    Oct 22, 2022
    Posts:
    7
    I am sorry. I don't understand what you mean
     
  6. kei233

    kei233

    Joined:
    Dec 16, 2019
    Posts:
    49
    There is an IPointerClickHandler, maybe you can try, to replace the up/down one.
    or maybe reset and stop the rotating at IBeginDragHandler