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
Hello, do you $$anonymous$$d accepting my answer since it is correct. It really makes me stay motivated to answer these questions.
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.
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
Follow this Question
Related Questions
Tag control 0 Answers
Beginner trying to add animation 0 Answers
Activating Scripts in another Script? 2 Answers