Scroll View add content at runtime

Hi,

In a game i’m making i need to spawn a scroll view in the scene and fill it with a list of card data. Meaning, that i will have a “card” object in the scene (with a picture slot and a name slot), and when the scroll view (in my game, it is some kind of “tab” with options) spawns, i duplicate the card object and put it in the “content” child of the scroll view (as often as the number of data entries in the list). for each card i then set the image and name. However, i would like it if the cards would space out evenly in the scroll view container. Is there a component that can take care of this or does this need to be done manually? and if so, how do you do that?

For the people familiar with Unity, there is a component called “content size fitter” and “Horizontal/vertical layout group” that will make sure the container fits all it’s content (by growing in size) and then spread them out evenly next to eachother (in a horizontal or vertical way, depending on the component). I’m actually looking for the same thing here in PlayCanvas. Any ideas?

Thanks in advance

1 Like