Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: FOX_ITA on January 27, 2014, 03:27:09 PM
Title:
UIGrid, how to get the index from a child
Post by:
FOX_ITA
on
January 27, 2014, 03:27:09 PM
Hello there,
i'm pretty new to NGUI and i'm using it a lot.
But i can't figure out hot to determinate the index of a child clicked on the UIGrid.
I got a UIScrollView with attached an UIGrid with as a children different UIButtons.
How can i get the index or position of pressed button in the grid?
for example if i click on the first one i can see that is pressed the item 0 into the UIGrid.
Many thanks,
cheers!
Title:
Re: UIGrid, how to get the index from a child
Post by:
Nicki
on
January 27, 2014, 04:35:31 PM
//assuming this is on the child
UIGrid gridReference
;
void
OnClick
(
)
{
int
xPos
=
transform
.
localPosition
.
x
;
int
index
=
(
int
)
xPos
/
gridReference
.
cellWidth
;
//or cellheight
}
Title:
Re: UIGrid, how to get the index from a child
Post by:
FOX_ITA
on
January 28, 2014, 07:50:51 AM
Thanks a lot,
i'm gonna test it right now!