Support => NGUI 3 Support => Topic started by: ysrikanth2011 on April 25, 2014, 06:07:27 AM
Title: How to know the index of the item present in the grid i am clicking.
Post by: ysrikanth2011 on April 25, 2014, 06:07:27 AM
Hi ,
I have a vertical scrollview which has items scrolling. I have added a grid under it and some sprites under the grid . How to know Which item(index) that I am clicking now ? I have seen the UIScrollView and UIGrid class , but I did not found any supporting method .
Please let me know a possible way of doing this .
Thanks in Advance.
Title: Re: How to know the index of the item present in the grid i am clicking.
Post by: ArenMook on April 25, 2014, 10:07:42 AM
Which item you are clicking on, or the index of the item? They are different things. UIGrid's GetChildList() gives you the list of children, and you can do IndexOf to find the index.
Title: Re: How to know the index of the item present in the grid i am clicking.
Post by: ysrikanth2011 on April 26, 2014, 06:39:28 AM
I actually want to know the index of the item currently clicked. I know the method "UIGrid.GetChildList()" but where is the "indexof()" method ?
Title: Re: How to know the index of the item present in the grid i am clicking.
Post by: ArenMook on April 26, 2014, 03:15:43 PM
Hmm... may not be in 3.5.8. Add this to BetterList:
/// <summary>
/// Return the index of the specified item.
/// </summary>
publicint IndexOf (T item)
{
if(buffer ==null)return-1;
for(int i =0; i < size;++i)if(buffer[i].Equals(item))return i;