Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by siddharth3322 · Mar 22, 2014 at 05:49 PM · buttonunity4.32dtoolkittk2d

Know Which Button is Clicked

I have eight buttons on screen that I created using 2d Toolkit.

Following image demonstrate my hierarchy window.

alt text

Following image demonstrates component that I have added for each button.

alt text

Buttons object contain a script called ButtonController in which code for each button exist. In this I want information about which button is clicked by player. For that button I want to do some changes.

Please give some suggestions.

EDIT : Basic working of tk2dButton is, It calls specified method. We don't need to add collider to any object to execute click event.

More detail about my question and I am assuming that I am not using tk2d at all only normal button which has collider attached and sending message to my parent Buttons object.

I have script that contain single method in that and assigned to Buttons object. I want to know which button is clicked. Several buttons attached to Buttons parent object.

I think, now I have given more detail. If you want any further detail then I will provide but I want some nice suggestion for this.

screenshot 2014-03-22 23.17.18.png (51.4 kB)
screenshot 2014-03-22 23.16.01.png (12.8 kB)
Comment
Add comment · Show 8
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image getyour411 · Mar 22, 2014 at 07:32 PM 0
Share

How are you doing 'is clicked by player' - I think gameobject.name should be retrievable via that.

avatar image bdorn14 · Mar 22, 2014 at 07:46 PM 0
Share

Like left and right buttons on the mouse?

avatar image getyour411 · Mar 22, 2014 at 07:50 PM 0
Share

I think you are asking about Raycast. You Raycast and look to see what you hit, and if you hit a button (which you might get via hit.gameobject.name or tag) then you'd pass off to ButtonController.

Take a look at Raycast and see if that's what you are asking about.

avatar image siddharth3322 · Mar 23, 2014 at 05:58 AM 0
Share

First gameobject.name give me name of buttons as name. Second I don't need to use ray cast here because I am using tk2dButton here.

avatar image getyour411 · Mar 23, 2014 at 06:33 AM 0
Share

TBH I don't know what you are asking - how can you not know which button is clicked? The screenshots don't tell me anything and I don't use tk2dButton.

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Placing button at corner using NGUI 2 Answers

Trigger single collision event 2 Answers

Atlas size based on sprite 0 Answers

Water Fire Effect On 2d Game 1 Answer

Main character always attached with ground 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges