I’m trying to create a menu that shows a certain amount of levels per page, (so more than 6 levels will add another page).
But my pages.levels list is showing the “Level 01” 6 times in both page lists, where it should be the first 6 levels in the first and only level 07 in the second (I’m using 7 strings as ‘levels’ currently)
[35958-screen+shot+2014-11-27+at+19.34.47.png|35958]
PagesHandler.cs
public class PageHandler {
public int index;
public List pages;
}
Page.cs’
public class Page {
public List levels;
}
This is my MainMenu.CS
public List<string> levels;
public PageHandler pageHandler;
int pageCount = 1;
int count = 0;
void Start () {
//Check How Many Pages Needed
for (int i = 0; i < levels.Count; i++) {
if (count == 5) {
pageCount++;
count = 0;
} else {
count++;
}
}
//Set Page Handler
pageHandler = new PageHandler ();
pageHandler.pages = new List<Page>(pageCount);
for (int j = 0; j < pageCount; j++)
{
pageHandler.pages.Add(new Page());
pageHandler.pages[j].levels = new List<string>();
}
//Add levels to page
for (int k = 0; k < levels.Count; k++)
{
for (int l = 0; l < pageHandler.pages.Count;)
{
if(pageHandler.pages[l].levels.Count == 6)
{
l++;
} else {
pageHandler.pages[l].levels.Add(levels[k]);
}
}
}
}
Thanks!