admin管理员组

文章数量:1122832

I use Unity3D viewport

Inside the viewport

content

  • button_1

-transform_1

  • Button_2

  • tranform_2

  • Button_3

. . .

It's arranged like this

When each button is clicked, an input field is created to enter a specific value in the transform position

The generated input field has a + button, which creates an input field when the + button is pressed, and I want to make the button_2 or button_3 naturally push down as much as the newly created input field space!

  • button_1

  • Input Field_1

  • Input Field_2

  • Input Field _3

-Button_2

I want this way, but if I press the + button in the input field_1, there is a problem that occurs in the space between button_1 and button_2, and button_2 is not pushed down, but I have no idea how to solve it, so I leave a message

public void AddSizeInputField()
{
    GameObject newSizeInput = Instantiate(sizeInputPrefab, sizeInputContainer);
   
    // LayoutRebuilder.ForceRebuildLayoutImmediate(sizeInputContainer.GetComponent<RectTransform>());

    InputField[] inputs = newSizeInput.GetComponentsInChildren<InputField>();
    Button addButton = newSizeInput.GetComponentInChildren<Button>();
    addButton.onClick.AddListener(AddSizeInputField);
    inputs[0].onEndEdit.AddListener(delegate { SaveSize(inputs); });
    inputs[1].onEndEdit.AddListener(delegate { SaveSize(inputs); });

    SaveSize(inputs);
}

my code

本文标签: cUnity vertical layout group QuesitionStack Overflow