Hello Guest

Author Topic: Find which button call click method  (Read 4602 times)

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Find which button call click method
« on: November 28, 2014, 01:45:46 pm »
For my game, I have level selection scene and it contains 30 buttons in it.
In each button I have added Tk2dUIItem script to it. This script's Target contains scripts that contains click methods in it.
This script's OnClick parameter combo box I have selected method that this button need to call.

At present the condition is, I have to create thirty methods for each button. As per my assumption this thing is wrong so if I can able to know which object calling this method then only single method become enough for me.

If you have any better way to implement this situation then please give some help.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Find which button call click method
« Reply #1 on: November 29, 2014, 11:32:46 am »
The event handler can have an optional tk2dUIItem parameter. This returns the selected object, and you can use that in a shared event handler.

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Find which button call click method
« Reply #2 on: November 30, 2014, 08:01:36 am »
Thanks for your reply.
I have searched for tk2dUIItem parameters but I can't able to get it.

https://www.dropbox.com/s/ve8p1b1b4gmmqqc/Screenshot%202014-11-30%2013.27.52.png?dl=0

I have also read tk2dUIItem script but in that I can't say any parameter variable. So you have to give some more help to me.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Find which button call click method
« Reply #3 on: November 30, 2014, 12:44:36 pm »
The function you create takes a tk2dUIItem parameter.
Like
void DoSomething(tk2dUIItem thingThatCalledMe)
{
}