- Home /
Find which button call click method in 2d Toolkit
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.
Answer by siddharth3322 · Dec 10, 2014 at 10:56 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.
The function you create takes a tk2dUIItem parameter. Like
void DoSomething(tk2dUIItem thingThatCalledMe)
{
}
I have got this answer in following forum post. tk2d Forum
Your answer
Follow this Question
Related Questions
Code behaving differently after LoadLevel() 0 Answers
Multiple languages support 1 Answer
Font blurring in Ipad 0 Answers
How to setup Sprites as HUD/UI? 0 Answers
Know Which Button is Clicked 0 Answers