- Home /
ArgumentOutOfRangeException: Help?
I'm getting this error : ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count.
in response to:
var card : Object = gridArray[i][j];
in:
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
for(var i=0; i<rows;i++)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
for(var j=0; j<columns;j++)
{
var card : Object = gridArray[i][j];
if(GUILayout.Button(Resources.Load(card.img),GUILayout.Width(cardWidth)))
{
Debug.Log(card.img);
}
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
does anyone know what's going on? I'm following a tutorials and was kindof hoping that the code would be bug free but I must have made a mistake somewhere.
I'm having the same issue with the same book. I mean, I could download the source code from the publisher site and get it to run, but I want to understand what is giving that error and more importantly, WHY.
How are 'rows' and 'columns' set? How are they declared? Can you post more code (edit your answer).
They should be set globally earlier:
var columns:int = 4; var rows:int = 4;
Your answer
![](https://koobas.hobune.stream/wayback/20220613070612im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
problem with FindWithTag 2 Answers
Using List.Count on Unity iPhone 2 Answers
What am I doing wrong with hashtable.CopyTo? 1 Answer
Reading a File into a Byte Array 2 Answers