Draggable

The Draggable component is used to change position, like dragging a window by header. It shouldn’t be confused with Drag and Drop.

Options

  • Interactable bool

    Allow interaction.

  • Handle GameObject optional

    GameObject used to drag current GameObject.

  • Horizontal bool

    Allow horizontal drag movement.

  • Vertical bool

    Allow vertical drag movement.

  • Restriction DraggableRestriction:

    • None: no restriction.

    • Strict: does not allow drag outside the parent.

    • After Drag: does not allow drag outside the parent, applied after drag ended.

  • Curve AnimationCurve

    Animation curve used to animate applied After Drag restriction.

  • Unscaled Time bool

    Run animation with unscaled time.

  • Snap Grids List<SnapGridBase>

    Allow snapping the RectTransform position to the nearest line.
  • Snap Distance Vector2

    Maximum distance to lines where snapping is available.

Properties

  • Target RectTransform

    Target to drag; the self is by default.

Events

  • OnStartDrag UnityEvent<Draggable>

  • OnDrag UnityEvent<Draggable>

  • OnEndDrag UnityEvent<Draggable>

  • OnSnap = UnityEvent<Draggable, SnapGridBase.Result>

  • OnEndSnap = UnityEvent<Draggable, SnapGridBase.Result>

  • OnTargetChanged UnityEvent<Draggable>