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 /
This question was closed May 12, 2013 at 01:59 AM by TheDarkVoid for the following reason:

Other

avatar image
0
Question by TheDarkVoid · Jul 14, 2012 at 12:10 AM · c#inputkeycode

Key binding screen

i am trying to create a menu that would allow users to modify key bindings. here is the code i have: GUI:

 GUI.Label(new Rect(50, 0, 100, 20), "Zoom Out:");
 if(GUI.Button(new Rect(200, 0, 200, 20), ZoomOutTxt))
 {
  L_ZoomOut = true;
  ZoomOutTxt = "Press a Key.";
  Screen.lockCursor = true;
 }
 //ZoomIn
 GUI.Label(new Rect(50, 20, 100, 20), "Zoom In:");
 if(GUI.Button(new Rect(200, 20, 200, 20), ZoomInTxt))
 {
  L_ZoomIn = true;
  ZoomInTxt = "Press a Key.";
  Screen.lockCursor = true;
 }

the input listener in the Update()

 if(L_ZoomOut)
 {
  if(CheckKey(e.keyCode))
  {
  ZoomOut = (int)e.keyCode;
  ZoomOutTxt = ((KeyCode)ZoomOut).ToString();
  Screen.lockCursor = false;
  L_ZoomOut = false;
  }else
  {
  L_ZoomOut = false;
  ZoomOut = PlayerPrefs.GetInt("ZoomOUT", D_ZoomOut);
  ZoomOutTxt = ((KeyCode)ZoomOut).ToString();
  Screen.lockCursor = false;
  }
 }
 if(L_ZoomIn)
 {
  if(CheckKey(e.keyCode))
  {
  ZoomIn = (int)e.keyCode;
  ZoomInTxt = ((KeyCode)ZoomIn).ToString();
  Screen.lockCursor = false;
  L_ZoomIn = false;
  }else
  {
  L_ZoomIn = false;
  ZoomIn = PlayerPrefs.GetInt("ZoomIN", D_ZoomIn);
  ZoomInTxt = ((KeyCode)ZoomIn).ToString();
  Screen.lockCursor = false;
  }
 }

this key checker:

 bool CheckKey(KeyCode key)
 {
  if(ForbiddenKeys.Contains((int)key))
  {
  return false;
  }else
  {
  return true;
  }
 }

the problem is when i click the button it changes to None the list of forbidden keys are as follows: escape, capslock, f1 - f12, and mouse0 as keycodes any suggestions.

Comment
Add comment
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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

C# Script Simulating Input.inputString 0 Answers

Last key pressed 1 Answer

Issue With Lists and Keycodes 1 Answer

Dynamic KeyCode Unity Exception 2 Answers

How to Use Key Combinations with the Control-Key? 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