• 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 chloe804 · Apr 19, 2016 at 09:13 PM · c#androiduibuttonstring

How can I make a UI button press affect something in a text box?

Hello,

Firstly, I am a beginner at coding.

I am trying to make a typing application on touch screen devices, so I have created my own keyboard (all individual buttons per letter of the alphabet), however I want it so that when the user presses a key - for example 'C' - the key they pressed appears above the keyboard in a text box; so if they pressed 'C', 'A', 'T', the string outputted in the text box would read "CAT".

However, I have literally no idea how to go about this as nothing I have tried is working, and nothing I have searched online has worked.

NB: I need to use my own keyboard with all the buttons because the application's idea is to teach correct finger placement and quicker typing, so I wouldn't be able to use the user's own keyboard

Comment
Add comment · Show 5
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 incorrect · Apr 19, 2016 at 09:27 PM 0
Share

Why not using Input Field and native device keyboard ins$$anonymous$$d?

Also I'd recommend you look at the Learning Section. You can find lots of answers there.

avatar image chloe804 incorrect · Apr 19, 2016 at 09:48 PM 0
Share

Ahh, I forgot to add that I need to use my own keyboard because the idea for the application is to $$anonymous$$ch the user the correct finger placement and eventually speed up their touch typing, so I wouldn't be able to interact with their native device keyboard

avatar image incorrect chloe804 · Apr 19, 2016 at 10:07 PM 0
Share

So you need to make a script that will add a letter to the string and put that string into displayed text box.

avatar image chloe804 incorrect · Apr 19, 2016 at 10:28 PM 0
Share

I guess, yeah. I know the theory of it and the pseudo code, but not the actual code.. That's what my question was.

I've ran into a bunch of errors about not being able to convert the UI.Button to a string, or a char, or even a bool, so I'm back to square one with no code and even less ideas than I had before.

avatar image incorrect chloe804 · Apr 20, 2016 at 08:33 AM 0
Share

Try watching tutorials in Scripting Tutorial Section. Your question is about general program$$anonymous$$g and is not quite Unity-specific.

What you actually need to do is attaching a script like this to each button.

 [SerializeField]
 private Text displayText;
 
 [SerializeField]
 private string letter = "";
 
 public void AddButton()
 {
     display.text = display.text + letter;
 }

Set references to display field and letters and assign AddButton() method on button press event.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

Someone please help me with combination lock 0 Answers

I have some problem with mobile input (keyboard) 0 Answers

Button Displacement 0 Answers

UI button events not working on android 3 Answers

Remove button OnMouseOver highlighting 0 Answers


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