- Home /
Filling GUI.BeginScrollView with images
Hey all,
within my GUI you'll see this:
Function OnGUI(){
scrollViewVector = GUI.BeginScrollView (new Rect (140, 10, 768, 532), scrollViewVector, new Rect (0, 0, 12000, 512));
for(var i=0;i<images.Length;i++){
GUI.DrawTexture(Rect (0, 0, 768, 512), images[i]);
}
GUI.EndScrollView ();
}
What, I'm trying to do is populate the scroll box with images, but the loop only shows the last one (which I understand why) what i don't know how to do is basically retrun all array elements? So I ask how I would do that...
Thanks, Josh.
Answer by TonyLi · Jul 13, 2013 at 01:12 PM
So instead of specifying the same position for all the textures (Rect(0,0,768,512)), you could do one of two things:
Increment the position for each image:
for(var i=0;i<images.Length;i++){ GUI.DrawTexture(Rect (0, i*512, 768, (i+1)*512), images[i]); }
Or let GUILayout do the work:
for(var i=0;i<images.Length;i++){ GUILayout.Label(images[i]); }
Can not complain here, and I learn something new :)
Thank you :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613110030im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Gathering GameObjects and then creating a button for each GameObject?? 2 Answers
GUILayout.BeginScrollView how to create new row? 0 Answers
Can't destroy an arrray with GUI Text 1 Answer
Arrange ints from biggest to smallest and display them in a table 1 Answer
GUI.BeginScrollView - How to customize the vertical scroller to add padding. 0 Answers