Draggable.cs 515 B

123456789101112131415161718
  1. using UnityEngine;
  2. using UnityEngine.EventSystems;
  3. namespace SoftMasking.Samples {
  4. [RequireComponent(typeof(RectTransform))]
  5. public class Draggable : UIBehaviour, IDragHandler {
  6. RectTransform _rectTransform;
  7. protected override void Awake() {
  8. base.Awake();
  9. _rectTransform = GetComponent<RectTransform>();
  10. }
  11. public void OnDrag(PointerEventData eventData) {
  12. _rectTransform.anchoredPosition += eventData.delta;
  13. }
  14. }
  15. }