Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Request for Simple Github Project with UIToolkit + New Input System

Discussion in 'UI Toolkit' started by tacman1123, Nov 19, 2020.

  1. tacman1123

    tacman1123

    Joined:
    Sep 14, 2020
    Posts:
    56
    Is there a simple project that shows working UI Toolkit examples?

    I'm really having a hard time following the setup. I've watched videos and read through the threads, but I can't quite figure out how to put the pieces together. Panel Renderer, UI Elements, UI Toolkit, etc.

    I've hacked away at the Unity Battle Royale project, and a bit with the tanks project, but was hoping for something simpler, more along the lines of the Game Jam Menu template (a main menu with Start, Settings, About, Quit) -- something simple like that would be wonderful to play with.

    Thanks,

    Tac
     
    Last edited: Nov 19, 2020
  2. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    245
  3. tacman1123

    tacman1123

    Joined:
    Sep 14, 2020
    Posts:
    56
    Yes, I've spent a few hours with that project, but I can't figure out how to extract what I need to do a simple project (e.g. a main menu with an option to change some settings).

    Plus, that project uses the old Input Manager, I'm wondering if it's possible to use the new Input System.
     
  4. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    245
    What parts are you having trouble with?

    The new input system is supported: https://forum.unity.com/threads/feedback-wanted-new-input-system-support.963111/
     
  5. tacman1123

    tacman1123

    Joined:
    Sep 14, 2020
    Posts:
    56
    I think I've set up everything correctly, but how do I actually display a menu or part of it?

    That is, I have ]

    Code (css):
    1.  
    2. /*AppStyle.uss*/
    3. Label {
    4.     font-size: 20px;
    5.     -unity-font-style: bold;
    6.     color: rgb(68, 138, 255);
    7. }
    8.  
    Code (xml):
    1.  
    2. <!--AppVisualTree.uxml-->
    3. <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
    4.     <Style src="AppStyles.uss" />
    5.     <ui:VisualElement>
    6.         <ui:Label text="Label" display-tooltip-when-elided="True" style="-unity-background-image-tint-color: rgba(209, 117, 28, 255); font-size: 58px;" />
    7.     </ui:VisualElement>
    8.     <ui:Button text="Start Game&#10;" display-tooltip-when-elided="True" name="start-game" />
    9. </ui:UXML>
    I assume at this point I need to attach a script somewhere (to the UIDocument parent perhaps?) and display the visual element. That's the part I'm stuck on.

    Thanks.

    Tac
     
  6. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    245
    So I imported your xml and uss into a empty project and got it working.

    Make sure this matches your UIDocument in the scene view. Also, I had to toggle the GameObject's active/inactive toggle to get it to show up.



    Here is UIBuilder:



    lmk if you still have issues!
     
    Last edited: Nov 19, 2020
  7. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    209
    This is an issue we're aware of and fixing. Also pressing the play button would make it show up.

    Thanks for helping other users, we appreciate it! :cool:
     
  8. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    245
    Cool!

    No problem! Glad I can help :)
     
unityunity