Hello Guest

Author Topic: tk2dUIItem array  (Read 3555 times)

vivaldi

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 15
    • View Profile
tk2dUIItem array
« 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.

vivaldi

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: tk2dUIItem array
« Reply #1 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

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dUIItem array
« Reply #2 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.