- Home /
Adding a button to the content of the viewport in a scroll view through code?
GameObject newButton = Instantiate(buttonPrefab);
I am trying to figure out how to set my newButton as a child of the content of the viewport of a pre-existing scroll view with just code. Call the pre-existing scroll view genericScrollView.
Do I declare the newButton to be a GameObject or a Button? Do I declare the Scroll View to be a GameObject or a ScrollView?
If the viewport is already made and is a child of the scroll view and the content is already made and is a child of the viewport, how do I make my newButton a child of the content of the viewport of the scroll view?
Your answer
Follow this Question
Related Questions
ScrollRect content position is wrong in build 2 Answers
vertical layout problem using prefab buttons 1 Answer
ScrollView runtime Instantiating button in the content 1 Answer
Scroll content disappears after trying to scroll on Android, on different aspect ratio devices. 0 Answers
Scroll View not scrolling 1 Answer