when i set canvas to screen space overlay, the UI is visible during dragging, but when i set the canvas to screen space camera it is not visible while dragging, and i just need drag in screen space camera. Here is my drag code:
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class Drag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler {
public Transform parentToReturnTo=null;
public void OnBeginDrag(PointerEventData eventData){
Debug.Log ("OnBeginDrag");
parentToReturnTo = this.transform.parent;
this.transform.SetParent (this.transform.parent.parent);
GetComponent<CanvasGroup> ().blocksRaycasts = false;
}
public void OnDrag(PointerEventData eventData){
Debug.Log ("OnDrag");
this.transform.position = eventData.position;
}
public void OnEndDrag(PointerEventData eventData){
Debug.Log ("OnEndDrag");
this.transform.SetParent(parentToReturnTo);
GetComponent<CanvasGroup> ().blocksRaycasts = true;
}
}