Search Unity

Bug 'DragExitedEvent' does not exist in the namespace 'UnityEngine.UIElements

Discussion in 'UI Toolkit' started by achimmihca, Apr 27, 2023.

  1. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    283
    My code works in the editor, but when I try to build for Windows I get an error message:
    Code (CSharp):
    1. error CS0234: The type or namespace name 'DragExitedEvent' does not exist in the namespace 'UnityEngine.UIElements' (are you missing an assembly reference?)
    2.  
    Above error message appears with explicit usage of
    UnityEngine.UIElements.DragExitedEvent
    . With using statement (
    using UnityEngine.UIElements
    ) I get

    Code (CSharp):
    1. The type or namespace name 'DragExitedEvent' could not be found (are you missing a using directive or an assembly reference?)
    2.  
    I am using Unity 2022.2.4f1 and UIElements is a built-in module. Plus, the code works fine in the editor.
    Do I need to add another module to the asmdef file, or is this a bug?

    You can find the demo project here: https://github.com/achimmihca/Unity-UIToolkit-ListViewHorizontal
    I created a horizontal ListView by decompiling Unity's vertical ListView and swapping everyhting vertical with horizontal.
     
  2. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    283
    I removed all references to the drag events and now it seems to work fine.

    Still, I think this is a bug.
    Either the symbols should not be exposed in the Unity editor, or they should also be exposed when building for a target platform.
     
  3. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    Drag events are not supported in the player. It's a bit counter-intuitive because the event is available in the runtime namespace, but the best we could do is to exclude in the Player assembly.

    Note that it shouldn't work in the GameView. Is that what you observed when you said "It works fine the Editor" ?