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
0
Question by Supershandy · Feb 16, 2014 at 11:03 AM · javascriptuiguinguikeycode

NGUI/GUI button emulating Keyboard letter press

Hiya,

Just wondering if it's possible to get a NGUI/GUI button to emulate a letter on a keyboard as there is an asset that i'm using that using keyboard controls to select targets and since the game is for mobile, I don't really want the keyboard on screen as it will take up too much room.

i.e if i press a button (SelectNextTarget) I want it to be able to select the letter t (Keycode = KeyCode.T) which would select the next target.

I know I can bind a button to a key so that the key selects the button, but I would like it to go in reverse....

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 vexe · Feb 16, 2014 at 11:16 AM 0
Share

A Windows-only solution it to send keys via windows api.

avatar image Supershandy · Feb 16, 2014 at 11:18 AM 0
Share

A little vague...could you explain a bit more please?

avatar image getyour411 · Feb 16, 2014 at 11:25 AM 0
Share

What is specific about the letter T? Can you do something like

 if(GUI.Button(buttonDims_for_SelectNextTarget)) {
 // call SelectNextTarget function that used to be called when someone pushed the letter "T"
 }
avatar image Supershandy · Feb 16, 2014 at 11:37 AM 0
Share

I figured out where i was going wrong, seems you cant bind a button to a keyboard letter, but the asset i used sent the key bindings to another script which had the functions i was trying to use

avatar image vexe · Feb 16, 2014 at 04:42 PM 0
Share

@Supershandy: You could use the SendInput function to send/emulate any kind of input (mouse or keyboard), msdn, stackoverflow. It's a bit cumbersome and windows-only as I mentioned before. But I managed to successfully get it to work, for example. If you want to go this way, let me know, I think I have the code somewhere for sending keyboard keys.

1 Reply

· Add your reply
  • Sort: 
avatar image
-1

Answer by unimechanic · Feb 22, 2014 at 01:50 AM

Question solved according to comments:

  • figured out where i was going wrong, seems you cant bind a button to a keyboard letter, but the asset i used sent the key bindings to another script which had the functions i was trying to use*

[Adding this answer to remove it from the Unanswered list.]

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 whydoidoit · Feb 22, 2014 at 01:54 AM 1
Share

Surely it's preferable to convert the comment and mark it answered. While I realise that this will award $$anonymous$$arma to the questioner, it would seem better in this case to have it marked correct.

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

Use Unity UI For 2D Games Or Custom Objects Instead? 2 Answers

In-game text editor, native or NGUI 2 Answers

Cropped Label Problem - Big Font - Unity3D 1 Answer

How to see NGUI in SceneView 1 Answer

Is unity gui good to use 2 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