Don't understand List<GameObject>

privateListm_arrayButtons=newList();

If I add one element to this then m_arrayButtons.Count is 7…WTF???

How do I get the number of elements so I can loop through the list?

There does not seem to be an appropriate data member or function.

What the hell happens if I try and do this:

for (int i = 0; i < m_arrayButtons.Count; i++)
Debug.Log(m_arrayButtons*);*

There certainly shouldn’t be 7 elements in your list, if you only added one. Please show the code where you add one element and write out the count of m_arrayButtons.

Your second example should probably be:

for ( int i = 0; i < m_arrayButtons.Count; i++)
   Debug.Log(m_arrayButtons[i].name);

You forgot the subscript. So you were trying to write the entire array.Also, as far as I remember, trying to convert a gameobject to a string just gives its type, so you have to use pick something useful about the gameobject to write out, such as the name.

Never mind cblarsen, I was carrying out an unnecessary step before adding each element to the array and some how it was adding it seven times.

I eliminated that unnecessary step and .Count contained what I expected it to contain.