Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by MauBel · Oct 01, 2016 at 09:07 AM · c#beginnergetcomponenttag

Tag Reading

Hi Folks,

I'm an absolute Noob, so forgive me in advance for this silly question...

I'm building a small 2D interactive application for my students. I have 43 UI Buttons (name: keyBtn(a)..(b) etc.) belonging to Canvas. Each of them has its own tag (A..B..C..) representing letters, numbers and special keys. I have a 2D Text (name: scratchPad) which shall show the final result of the clicked buttons.

1) How to "read" the tag of each of the buttons when I click one of them; in Unity Manual and Script I am not able to find the correct routine to read a tag... I know I am a superNoob... the GetComponent doesn't work at all for me...

2) I want to store the tag into a string (ok, that's superSimple) and

3) add this string to the UI Text scratchPad and show it on the screen; practically, to "pass" the string.

Thanks for the help

Comment
Add comment · Show 1
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 AurimasBlazulionis · Mar 28, 2017 at 05:15 PM 0
Share

Hello, do you $$anonymous$$d accepting my answer since it is correct. It really makes me stay motivated to answer these questions.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AurimasBlazulionis · Oct 01, 2016 at 10:27 AM

When you press a button, pass it's transform to a function. Then in a function you can use something like passedTransform.tag to read the tag. You can store it in a variable.

To show the tag on a text, have a variable which points to UI.Text type. Just set the string to thatTextvariable.text and you will be good to go.

Comment
Add comment · Show 1 · Share
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 MauBel · Oct 04, 2016 at 06:30 PM 0
Share

Thanks a lot, I will try.
However, I started reading a very GOOD $$anonymous$$anual to cope with my gaps... self-instruction will help me for sure (and I'll be more merciful with my students from now on!!)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Tag control 0 Answers

Beginner trying to add animation 0 Answers

Activating Scripts in another Script? 2 Answers

How can i get component as an abstract base class? 1 Answer

What is wrong with my code? C# beginner 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