Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Custom button inside ScrollRect not working as expected.

Discussion in 'UGUI & TextMesh Pro' started by LandHT, Jan 20, 2019.

  1. LandHT

    LandHT

    Joined:
    Feb 3, 2017
    Posts:
    84
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.EventSystems;
    3.  
    4. public sealed class CustomButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler {
    5.  
    6.     public void OnPointerDown (PointerEventData eventData) {
    7.         Debug.Log ("Down");
    8.     }
    9.  
    10.     public void OnPointerUp (PointerEventData eventData) {
    11.         Debug.Log ("Up");
    12.     }
    13.  
    14. }
    What is the difference between the Unity's Button and a custom button, like the above code, that makes dragging the ScrollRect trigger OnPointerUp instantly?

    I was hoping the OnPointerUp event to be triggered at drag end not at the start.

    The ScrollRect has the default options just the buttons inside the content.
     
    Last edited: Jan 20, 2019
  2. LandHT

    LandHT

    Joined:
    Feb 3, 2017
    Posts:
    84
    In the EventSystem component there is the Drag Threshold value to control the distance that needs for a drag to get recognized.

    This is a solution but there has to be something else going on cause with Unity's buttons it works flawlessly without modifying the drag threshold value (default is 5).