Guides
Guides
These docs are for v3.1.0. Click to read the latest docs for v3.3.0.

VRTK_UIDraggableItem

extends MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler

Overview

The UI Draggable item will make any UI element draggable on the canvas.

If a UI Draggable item is set to Restrict To Drop Zone = true then the UI Draggable item must be a child of an element that has the VRTK_UIDropZone script applied to it to ensure it starts in a valid drop zone.

Inspector Parameters

  • Restrict To Drop Zone: If checked then the UI element can only be dropped in valid a VRTK_UIDropZone object and must start as a child of a VRTK_UIDropZone object. If unchecked then the UI element can be dropped anywhere on the canvas.
  • Restrict To Original Canvas: If checked then the UI element can only be dropped on the original parent canvas. If unchecked the UI element can be dropped on any valid VRTK_UICanvas.
  • Forward Offset: The offset to bring the UI element forward when it is being dragged.

Class Variables

  • public GameObject validDropZone - The current valid drop zone the dragged element is hovering over.

Example

VRTK/Examples/034_Controls_InteractingWithUnityUI demonstrates a collection of UI elements that are draggable