2D Toolkit Forum

2D Toolkit => Support => Topic started by: vivaldi on February 06, 2014, 07:09:29 pm

Title: tk2dUIItem array
Post by: vivaldi on February 06, 2014, 07:09:29 pm
Hello,
I have array of tk2dUIItem:
Code: [Select]
public tk2dUIItem[] targets;
Code: [Select]
void OnEnable(){
for(int i = 0;i < targets.Length; i++){
targets[i].OnClick += targetClicked;
}
}

Code: [Select]
void OnDisable(){
for(int i = 0;i < targets.Length; i++){
targets[i].OnClick -= targetClicked;
}
}

How can I detect which button was pressed in my "targetClicked" method?
Thanks.
Title: Re: tk2dUIItem array
Post by: vivaldi on February 06, 2014, 07:51:09 pm
Ok, looks like i found solution.
I use OnDown instead OnClick and than in "targetClicked" get pressed stance
Code: [Select]
targets[i].IsPressed
Title: Re: tk2dUIItem array
Post by: unikronsoftware on February 06, 2014, 09:47:52 pm
You can just use OnClickUIItem, that passes you the UIItem that called the event. No need to hack around for this.