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. Dismiss Notice

Game window doesn't show the same as the UI Builder (Height issue)

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

  1. cedvdb

    cedvdb

    Joined:
    Jul 6, 2017
    Posts:
    6

    The containers in the UI Builder are taking the whole height of the canvas while in the game view it's taking only half of it.

    However when I change the reference DPI to 45 instead of 96 it seems to be taking the whole space. Is that normal ? What is going on ?
     
  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    Hello! Are you setting a specific size to your VisualElement? Because if you don't set a specific size and set flex grow to 1, it should take the whole screen, whatever the size is.
    The scale mode on your PanelSettings and the reference DPI depend on what the final outcome should be for your target device, but I highly recommend checking how to layout stuff with FlexBox properly before you go around playing with values.
    Hope that helps :)
     
  3. cedvdb

    cedvdb

    Joined:
    Jul 6, 2017
    Posts:
    6
    JuliaP_Unity I know how to layout stuff with flexbox, it's my job :D.

    So yeah I don't think the problem lies there, I think something is misconfigured in my project

    Fonts are not being displayed either. I'm new to unity so maybe Im missing something.

    Here is the repo
    https://github.com/cedvdb/drop3D (its now public)


    Below is the code used, which works when copy pasted in another project
    Code (csharp):
    1.  
    2. <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
    3.     <Style src="Test.uss" />
    4.     <ui:VisualElement class="root">
    5.         <ui:VisualElement class="child1" />
    6.         <ui:VisualElement class="child2" />
    7.     </ui:VisualElement>
    8. </ui:UXML>
    9.  
    10.  


    Code (csharp):
    1.  
    2. .root {
    3.     flex-grow: 1;
    4.     flex-shrink: 0;
    5.     background-color: rgb(255, 147, 0);
    6. }
    7.  
    8. .child1 {
    9.     flex-grow: 1;
    10.     margin: 15px;
    11.     background-color: rgb(0, 170, 187);
    12. }
    13.  
    14. .child2 {
    15.     flex-grow: 1;
    16.     margin: 15px;
    17.     background-color: rgb(0, 255, 255);
    18. }
    19.  
    PS: Although I don't know for sure, I've a feeling some packages might be clashing ?
     
  4. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    Hi again, awesome that you know flexbox! Many times here on the forums that's not the case so we tend to always suggest to look that up :)

    I opened your project here and no matter what type of scale mode I use for the PanelSettings, it always seems to take the full Game View - could it be a refresh problem there? Is it fixed if you press the Play button? We've had some of those and are working on fixing them, but not sure what's already live or not.
     
  5. cedvdb

    cedvdb

    Joined:
    Jul 6, 2017
    Posts:
    6
    Nope, it is not fixed by pressing play. Something is corrupted somewhere, I'm not sure where as I'm really new to unity. I'll try making a new project and copy paste everything to fix it.
    However I suspect it has something to do with the fact that my target build was android as it's the only thing that seems different with my test project

    Is there a cache clean command
     
    Last edited: Nov 20, 2020
  6. cedvdb

    cedvdb

    Joined:
    Jul 6, 2017
    Posts:
    6
    JuliaP_Unity Hey, so I fixed the issues by creating a new project and copy pasting the assets. I also found how to make a faulty project, this might interest you.

    So to make a faulty project here is what I did:

    - add com.unity.ui to the package manager
    - install ui builder
    - uninstall unity UI and mesh pro

    Then the game view isn't the same as in the UI Builder.

    I did uninstall those in my initial project because I thought those were not needed as the new ui system was the one used.

    However reinstalling text mesh pro on my initial project didnt resolve the issue but I'll keep going on the copy pasted project.
     
    JuliaP_Unity likes this.
  7. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    Thanks for reporting back! Yes the Unity UI package should remain installed at all times, at least for now :)
    Not sure about Text Mesh Pro, but maybe recent changes created some situation there.
    Good to know this could be an issue, we'll verify internally and see if there's something to be done about it (at least document it, of course).
     
  8. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    @cedvdb can you submit a bug from the project that is broken please? That will help us track this and fix it if there's something to fix! Thanks again
     
  9. CharlesQH

    CharlesQH

    Joined:
    Oct 9, 2020
    Posts:
    17
    In the PanelSettings asset of your UIDocument, set "Scale Mode" to "Constant Pixel Size". Try it.