Search Unity

UI Systems Roadmap

Discussion in 'UI Toolkit' started by jGate99, Apr 22, 2019.

  1. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,939
    Hi there,

    Is there a rough roadmap for UI Elements?
    For example when Drag Drop Editor is expected?

    Thanks
     
  2. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    1,000
    We don't have a public roadmap to share at this time, but we do have (basic) support for drag and drop operations. It still requires a bit of manual work. The drag&drop events can be used together with the UnityEditor.DragAndDrop class to ease the work a little bit. See this example:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5. using UnityEngine.UIElements;
    6. using UnityEditor.UIElements;
    7.  
    8. public class DragDrop : EditorWindow
    9. {
    10.     [MenuItem("Demo/Drag Drop")]
    11.     public static void DoIt()
    12.     {
    13.         GetWindow<DragDrop>().Show();
    14.     }
    15.  
    16.     void OnEnable()
    17.     {
    18.         var source = new VisualElement() {
    19.             style = {
    20.                 position = Position.Absolute,
    21.                 left = 20, top = 20, width = 100, height = 100,
    22.                 backgroundColor = Color.blue
    23.             }
    24.         };
    25.         source.Add(new Label() { text = "Source", style = { color = Color.black } });
    26.         source.RegisterCallback<MouseDownEvent>(OnSourceMouseDown);
    27.         rootVisualElement.Add(source);
    28.  
    29.         var dropZone = new VisualElement() {
    30.             style = {
    31.                 position = Position.Absolute,
    32.                 left = 200, top = 20, width = 100, height = 100,
    33.                 backgroundColor = Color.green
    34.             }
    35.         };
    36.         dropZone.Add(new Label() { text = "Drop Zone", style = { color = Color.black } });
    37.         dropZone.RegisterCallback<DragEnterEvent>(OnDragEnter);
    38.         dropZone.RegisterCallback<DragUpdatedEvent>(OnDragUpdated);
    39.         dropZone.RegisterCallback<DragPerformEvent>(OnDragPerfom);
    40.         rootVisualElement.Add(dropZone);
    41.     }
    42.  
    43.     void UpdateDrag()
    44.     {
    45.         DragAndDrop.visualMode = DragAndDropVisualMode.Link;
    46.     }
    47.  
    48.     void OnSourceMouseDown(MouseDownEvent e)
    49.     {
    50.         DragAndDrop.PrepareStartDrag();
    51.         DragAndDrop.StartDrag("Dragging");
    52.     }
    53.  
    54.     void OnDragEnter(DragEnterEvent e)
    55.     {
    56.         UpdateDrag();
    57.     }
    58.  
    59.     void OnDragUpdated(DragUpdatedEvent e)
    60.     {
    61.         UpdateDrag();
    62.     }
    63.  
    64.     void OnDragPerfom(DragPerformEvent e)
    65.     {
    66.         Debug.Log("Drag performed: " + e.target);
    67.         DragAndDrop.AcceptDrag();
    68.     }
    69. }
    70.  
     
    jGate99 and Lahcene like this.