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

Unable to export package depending on UI Elements

Discussion in 'UI Toolkit' started by quickytools, Oct 13, 2021.

  1. quickytools

    quickytools

    Joined:
    Aug 26, 2019
    Posts:
    19
    mac Big Sur 11.6
    Unity 2020.3.20f1
    com.unity.ui 1.0.0-preview.18

    I'm trying to export a package with an asmdef that has a reference to
    Code (CSharp):
    1. "references": [
    2.         "UnityEngine.UIElementsModule"
    3. ],
    but Unity cannot create it. Unity hangs (forever) after I type the package name and press save.

    I've attached the project if anyone can provide insight. The package is pretty bare (a single script and the .asmdef). The important file is the .asmdef which is also attached (renamed to UIElementsSample.txt).
    package-with-ui-elements-structure.png

    There seems to be some kind of error that flashes intermittently while the editor is open but it isn't persistent so I'm unable to read what it says.
     

    Attached Files:

  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    696
    Have you tried removing the check on "Auto Referenced" on your asmdef? I suspect that could be impacting this process.
     
  3. quickytools

    quickytools

    Joined:
    Aug 26, 2019
    Posts:
    19
    I tried it twice. Still hangs until I force quit the app. A dialog flashes but it closes so quickly I can't tell what it's trying to alert.
     
  4. quickytools

    quickytools

    Joined:
    Aug 26, 2019
    Posts:
    19
    It was due to this line in the script
    Code (CSharp):
    1. [RequireComponent(typeof(UIDocument))]
    .
    Don't know why this prevents a package from being exported but oh well. I'll work around it.
     
  5. quickytools

    quickytools

    Joined:
    Aug 26, 2019
    Posts:
    19
    Code (CSharp):
    1. [RequireComponent(typeof(UIDocument))]
    breaks exporting packages even when it is outside of an assembly definition (package). Hopefully it'll get fixed in a future update.
     
  6. quickytools

    quickytools

    Joined:
    Aug 26, 2019
    Posts:
    19
  7. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    696
    Exactly, in order to guarantee dependency order is respected, we need an Assembly Definition asset in the project if you're using the UI Toolkit package. This would not be necessary if you were using Unity 2021.2+ because you don't need the package with those versions (Runtime support is built in).