Dinamic Scroll bar

Hi everybody,

I´m trying to make a scroll bar to show several items in canvas panel. The items would be folder names saved, but the number of folder can change between app executions. How can I do to make a vertical scroll bar which show all the folders creating the new components of the scroll dinamically?

Thanks a lot!!

you need your “dynamic panel” to have a “scroll rect” component as well as one of the “layout” components which will grow/shrink the component to accommodate the contents.

dynamic panels is covered (in load more detail than you probably need) in this live training

Many thanks!! The link is very useful :wink: I have one more question, how can I put an image on the scroll buttons? In the video he do it with sprites, how can I transform my png pictures to a sprites from script?

I mean, I want to change button image from script at runtime. I have an png image saved and I want to use it like sprite in the button image, doing that from script, because this image will change between diferents app executions. I tried this:

GameObject newButton = Instantiate (sampleButton) as GameObject;
SampleButton button = newButton.GetComponent ();
byte[ ] imagenByte;
imagenByte = File.ReadAllBytes(Application.persistentDataPath+“/”+i+“/3.png”);
Texture2D imagenTexture = new Texture2D(2,2);
imagenTexture.filterMode = FilterMode.Trilinear;
imagenTexture.LoadImage(imagenByte);
imagenSprite = Sprite.Create(imagenTexture, new Rect(0,0,imagenTexture.width,imagenTexture.height), new Vector2(0.5f,0.5f));
button.imagen.overrideSprite=imagenSprite;

But I have one error: NullReferenceException: Object reference not set to an instance of an object

How can I fix that?

Thanks in advance!!