Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Where do I get UI Builder?

Discussion in 'UGUI & TextMesh Pro' started by Snackmix, Jan 30, 2020.

  1. Snackmix

    Snackmix

    Joined:
    Apr 3, 2013
    Posts:
    36
    I'm in the process of updating my game from 2018 -> 2019.3. I've run into a lot of issues but have been able to fix most of them. I'm having a lot of trouble with the UI now though.

    Before I had:
    Code (CSharp):
    1.  
    2.     public Button MoveButton;
    3.     public Button AttackButton;
    4.     public Button WaitButton;
    5.  
    6.     private void Start()
    7.     {
    8.         MoveButton.onClick.AddListener(OnMove);
    9.         AttackButton.onClick.AddListener(OnAttack);
    10.         WaitButton.onClick.AddListener(OnWait);
    11.  
    12.     }
    Now I lost the references I had set in the Inspector to each Button. Instead I thought I could change it to a GameObject and in Start I could call
    MoveButton = MoveButtonObj.GetComponent<Button>()


    When I do that though and click play I get an error that `ArgumentException: GetComponent requires that the requested component 'Button' derives from MonoBehaviour or Component or is an interface.`

    I've also had an issue where before for my hp bar I would set the image.fillAmount, but it appears that a UIElement.Image no longer has a .fillAmount on it, and I've searched through the docs but have not been able to find anything. I can still see Fill Amount in the inspector, but am unsure on how to reach it through code.

    I thought maybe I could just not use the new UIElement system, but it doesn't seem like I can use the old system anymore. I still have the Unity UI and TextMeshPro packages installed via Package Manager, but I'm unable to import and use them. The only one that will actually show up is Unity.UIElements, and I'm struggling.

    Would appreciate any help resolving these issues, or figuring out how I can just build my UI using the new UI Element system instead. I do not see UI Builder in the package manager, and I can't find it anywhere inside of the editor.
     
  2. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,890
    If you have
    using UnityEngine.UI;
    it should work. Button will be the UnityEngine.UIElements one.

    Or you can just change them to
    public UnityEngine.UI.Button MoveButton;
    , etc.
     
  3. MiguelOscarGarcia

    MiguelOscarGarcia

    Joined:
    Oct 19, 2019
    Posts:
    8
    UIBuilder is still a preview package. So in package manager you have to select Advanced>Show preview packages also.
    That won't solve your issues though, because it's not for runtime yet, only for editor. And it's a completely different UI system.
    So stick to UGUI for now.
     
    ysnyrk and ARBORK like this.
  4. Snackmix

    Snackmix

    Joined:
    Apr 3, 2013
    Posts:
    36
    Thanks! For some reason UnityEngine.UI and TMPro didn't exist as namespaces. I deleted my library and Assembly-Csharp, removed the packages, restarted and readded them and it fixed everything haha they exist now. Fun times!
     
    MiguelOscarGarcia likes this.
  5. ysnyrk

    ysnyrk

    Joined:
    Mar 30, 2019
    Posts:
    3

    i love u:)