Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Feedback Create => UI Document no longer creates a script - intentional?

Discussion in 'Unity 6 Beta' started by CodeSmile, Feb 15, 2024.

  1. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,922
    Editor 2023.3.0b7

    Creating a UI Document used to have this menu where you could choose to create the document, the stylesheet and the script (one or all of them).

    Now when I create a UI Document, it creates the document with a contained stylesheet. But there is no option to create a UI Document script, neither under UI Toolkit nor under Scripting.

    While the UI template script is pretty barebones it still allowed you to get started right away, and not make any mistakes referencing the correct document. This just adds unnecessary friction.
     
  2. martinpa_unity

    martinpa_unity

    Unity Technologies

    Joined:
    Oct 18, 2017
    Posts:
    505
    Hi @CodeSmile,

    Are you talking about creating a
    UIDocument
    game object with a side-along
    MonoBehaviour
    or are you talking about creating an
    EditorWindow
    ?

    The option to create an
    EditorWindow
    should still be available through "Assets /> Create /> UI Toolkit /> Editor Window".

    Hope this helps!
     
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,922
    I mean: RMB (project view) => Create => UI Toolkit => UI Document

    I realized afterwards I was getting the script creation option only with EditorWindow documents. This is so convenient I felt like left dead in the water making a runtime UI document without the option to create a script. Something I hadn't done in a long while so the difference in workflow came as a surprise.

    I had to look at examples to realize I needed the UI Document component on the GameObject which I reference from my UI MonoBehaviour.

    Now that you mention it I tried creating the UI document from within the scene. At least I got the UI Document already linked up that way, but still no corresponding MonoBehaviour template script. As a programmer, I find that desirable. If I were a UI designer, possibly not so much.
     
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,353
    Yeah, jeez, you don't want a companion script for every uxml file. Create => UI Document is just for arbitrary uxml files - they could be for runtime, they could be for the editor, they could be a thing you intend to nest into other documents, etc.