Skip to main content
package added.
Source Link

enter image description here

ScrollRectHolder holds ScrollRect component. The content of it is ScrollContent. Add Vertical Layout Group component on ScrollContent. It's also the parent of the buttons that will be instantiated each time you need. Button is the button prefab that will be instantiated. The variable initialHeight is the initial height of ScrollContent. Have to get it from Rect Transform of ScrollContent. Need to update sizeDelta with adding initialHeight whenever you add a new button.

public void AddNewButton()
{
 mRect.sizeDelta = new Vector2(mRect.sizeDelta.x, mRect.sizeDelta.y + initialHeight);
 GameObject gO = Instantiate(buttonPrefab);
 gO.transform.parent = transform;
}

enter image description here

enter image description here

enter image description here

unitypackage with scene, script and prefab. Unity 5.2.4f1.

enter image description here

ScrollRectHolder holds ScrollRect component. The content of it is ScrollContent. Add Vertical Layout Group component on ScrollContent. It's also the parent of the buttons that will be instantiated each time you need. Button is the button prefab that will be instantiated. The variable initialHeight is the initial height of ScrollContent. Have to get it from Rect Transform of ScrollContent. Need to update sizeDelta with adding initialHeight whenever you add a new button.

public void AddNewButton()
{
 mRect.sizeDelta = new Vector2(mRect.sizeDelta.x, mRect.sizeDelta.y + initialHeight);
 GameObject gO = Instantiate(buttonPrefab);
 gO.transform.parent = transform;
}

enter image description here

enter image description here

enter image description here

enter image description here

ScrollRectHolder holds ScrollRect component. The content of it is ScrollContent. Add Vertical Layout Group component on ScrollContent. It's also the parent of the buttons that will be instantiated each time you need. Button is the button prefab that will be instantiated. The variable initialHeight is the initial height of ScrollContent. Have to get it from Rect Transform of ScrollContent. Need to update sizeDelta with adding initialHeight whenever you add a new button.

public void AddNewButton()
{
 mRect.sizeDelta = new Vector2(mRect.sizeDelta.x, mRect.sizeDelta.y + initialHeight);
 GameObject gO = Instantiate(buttonPrefab);
 gO.transform.parent = transform;
}

enter image description here

enter image description here

enter image description here

unitypackage with scene, script and prefab. Unity 5.2.4f1.

layout orientation setup
Source Link

enter image description here

ScrollRectHolder holds ScrollRect component. The content of it is ScrollContent. Add Vertical Layout Group component on ScrollContent. It's also the parent of the buttons that will be instantiated each time you need. Button is the button prefab that will be instantiated. The variable initialHeight is the initial height of ScrollContent. Have to get it from Rect Transform of ScrollContent. Need to update sizeDelta with adding initialHeight whenever you add a new button.

public void AddNewButton()
{
 mRect.sizeDelta = new Vector2(mRect.sizeDelta.x, mRect.sizeDelta.y + initialHeight);
 GameObject gO = Instantiate(buttonPrefab);
 gO.transform.parent = transform;
}

enter image description here

enter image description here

enter image description here

enter image description here

ScrollRectHolder holds ScrollRect component. The content of it is ScrollContent. Add Vertical Layout Group component on ScrollContent. It's also the parent of the buttons that will be instantiated each time you need. Button is the button prefab that will be instantiated. The variable initialHeight is the initial height of ScrollContent. Have to get it from Rect Transform of ScrollContent. Need to update sizeDelta with adding initialHeight whenever you add a new button.

public void AddNewButton()
{
 mRect.sizeDelta = new Vector2(mRect.sizeDelta.x, mRect.sizeDelta.y + initialHeight);
 GameObject gO = Instantiate(buttonPrefab);
 gO.transform.parent = transform;
}

enter image description here

ScrollRectHolder holds ScrollRect component. The content of it is ScrollContent. Add Vertical Layout Group component on ScrollContent. It's also the parent of the buttons that will be instantiated each time you need. Button is the button prefab that will be instantiated. The variable initialHeight is the initial height of ScrollContent. Have to get it from Rect Transform of ScrollContent. Need to update sizeDelta with adding initialHeight whenever you add a new button.

public void AddNewButton()
{
 mRect.sizeDelta = new Vector2(mRect.sizeDelta.x, mRect.sizeDelta.y + initialHeight);
 GameObject gO = Instantiate(buttonPrefab);
 gO.transform.parent = transform;
}

enter image description here

enter image description here

enter image description here

Source Link

enter image description here

ScrollRectHolder holds ScrollRect component. The content of it is ScrollContent. Add Vertical Layout Group component on ScrollContent. It's also the parent of the buttons that will be instantiated each time you need. Button is the button prefab that will be instantiated. The variable initialHeight is the initial height of ScrollContent. Have to get it from Rect Transform of ScrollContent. Need to update sizeDelta with adding initialHeight whenever you add a new button.

public void AddNewButton()
{
 mRect.sizeDelta = new Vector2(mRect.sizeDelta.x, mRect.sizeDelta.y + initialHeight);
 GameObject gO = Instantiate(buttonPrefab);
 gO.transform.parent = transform;
}