Version: 2017.3
public GameObject pointerDrag ;

Descripción

The object that is receiving OnDrag.

Calling pointerDrag returns the GameObject this script is attached to. This is a ScrollView.

The parent of the pointerDrag can be set to null. This prevents OnDrag and OnEndDrag from being called.

// OnDrag() has the pointerDrag GameObject removed.
// This stops the cursor being moved.

using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI;

public class ExampleScript : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler { private float timeCount;

public void OnBeginDrag(PointerEventData data) { Debug.Log("OnBeginDrag: " + data.position); data.pointerDrag = null; }

public void OnDrag(PointerEventData data) { if (data.dragging) { timeCount += Time.deltaTime; if (timeCount > 1.0f) { Debug.Log("Dragging:" + data.position); timeCount = 0.0f; } } }

public void OnEndDrag(PointerEventData data) { Debug.Log("OnEndDrag: " + data.position); } }