Need help with UI scaling.

I’m having a bit of trouble with the UI system. Never quite understood it. Can someone explain how I stop this from happening:

This is how it looks in the editor and it’s also how I want it to look:

Now this is what it looks like in full screen 1920x1080:

This is what the button object looks like in the editor (while the game is not running):

This is the code for positioning the buttons:

void createButton(string id, string t, int i)
    {
        // Create a Button object
        if (buttonGameObject != null)
        {
            scrollPanel.GetComponent<Image>().enabled = true;

            scrollObject.GetComponent<RectTransform>().sizeDelta = new Vector2(scrollObject.GetComponent<RectTransform>().rect.width, d.GetNode(DialogueID.ToString()).options.Length * 85);
            scrollPanel.GetComponent<ScrollRect>().normalizedPosition = new Vector2(0, 1);

            GameObject b = Instantiate(buttonGameObject, new Vector3(10, 160 - (60 * buttonID)), Quaternion.identity);
            b.transform.SetParent(scrollObject.GetComponent<RectTransform>().transform);
            b.GetComponentInChildren<Text>().text = "" + t;
            UnityEngine.Events.UnityAction action1 = () => { this.onButtonClicked(id, i); };
            b.GetComponent<Button>().onClick.AddListener(action1);

            buttonID++;
        }
    }

How do I get it to look the same no matter the resolution?

I believe this option will work for you, unless the window can be resized to anything.

I tried to mimic your setup.
I created a panel which was setup to be on bottom and stretch width-wise.
then added 3 buttons
added vertical layout group to the panel (all 4 options selected).

Does that help ?

I did it by adding all the possible buttons ready onto the scene. Then adding them to an array. And just making them visible when they’re used and it workes great. But thanks for the help anyway.

Cool, glad you got it working…:slight_smile: