#Instantiating UXML incorrectly changes its size

1 messages · Page 1 of 1 (latest)

violet jackal
#

I have my UI Document Component set to use my .uxml file as its source asset, looking at the game view its displaying the UI correctly.
However, when I run the project, that same .uxml file suddenly shrinks.

This is the code that runs.
I know that it is loading and instancing the uxml that is already set in the inspector, its just a way to guarentee the correct uxml is always used

public class ConfigurationEditor : MonoBehaviour {
    UIDocument _doc;

    void Awake() {
        _doc = GetComponent<UIDocument>();
        LoadEditorUI();
    }

    void LoadEditorUI() {
        var visualTree = ResourceHelper.LoadEditorUXML();
        var instance = visualTree.Instantiate();
        _doc.rootVisualElement.Clear();
        _doc.rootVisualElement.Add(instance);
    }
}```
#

thats the result at runtime

#
.stretch {
    flex-direction: row;
    flex-shrink: 0;
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
}```The element that has the 3 columns uses this style, I would think that this should brute force it to be 100% size
candid snow
#

Most likely parent container won’t have stretch for whatever reason, you can check with debugger

grizzled frost
#

yea always check the debugger

#

I think when you do visualTree.Instantiate, there is a extra parent element