Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Drag&Drop assembly (IDragAndDropEvent) missing in builds

Discussion in 'UI Toolkit' started by _geo__, May 28, 2023.

  1. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,298
    Hi everyone!

    So, everything works fine in the Editor. However, if I try to make a build (default windows target) then I get the error that "The type or namespace name 'IDragAndDropEvent' could not be found".

    Actually it's not only the inferface, it's anything that has to do with drag and drop (any drag event class causes this).

    Tested in:
    Unity 2021.2.0f1
    Unity 2021.2.4f1
    Unity 2021.3.8f1
    and the latest LTS
    Unity 2021.3.26f1

    The test project is as simple as it can get. An empty project and just one script in the scene:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UIElements;
    3.  
    4. public class DragTest : MonoBehaviour, IDragAndDropEvent
    5. {
    6. }
    I have tried adding a reference to "UnityEngine.UIElementsModule" manually in the asmdef. Though that did not make any difference. I guess it's already there, so that makes sense.

    When I look at the interface itself then I see it is part of the UnityEngine.UIElements namespace. Therefore it should be included in the build, no?

    Code (CSharp):
    1. namespace UnityEngine.UIElements
    2. {
    3.     public interface IDragAndDropEvent
    4.     {
    5.     }
    6. }
    I have also tried deleting the library, caches, .. . Made new empty projects for testing, etc.

    Has anyone seen this behaviour?
    Maybe I am missing the forest for the trees here.
     
  2. oscarAbraham

    oscarAbraham

    Joined:
    Jan 7, 2013
    Posts:
    431
    It's known. Someone from Unity mentioned it in this thread: https://forum.unity.com/threads/dra...the-namespace-unityengine-uielements.1430083/

    DragAndDrop is a special system of the Editor, but they added those events to the UnityEngine namespace. Maybe there were once plans to have a DragAndDrop system at runtime? My guess is that it's too late to move them to UnityEditor now. I think they should add a notice in the docs, though.
     
    _geo__ likes this.
  3. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,298
    Thank you