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 Seth-McCumber · Jan 25, 2014 at 09:38 PM · not workingkeycodereturn

Return Acting As Space(4.3.2)

So basically, I try to use

 if(Input.GetKeyDown(KeyCode.Return)) {
  print("It Worked!");
  //Code stuff here, removed for example
 }

And where it says code stuff here, I set bools and such, but when I use it and hit return(enter) it calls the print, but not the bool setting and such. But strangely, when i hit the space bar, it does all of it, as if the spacebar was return. This only happens in this script, no others, and I have tried making a new script, it did nothing. Im not sure if this is a bug, but it may be. This really annoying and I need to figure it out. Thanks!

Comment
Add comment · Show 7
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 RecursiveRuby · Jan 25, 2014 at 10:14 PM 0
Share

This should work perhaps if you post the rest of the code we could get a better idea of what may be causing your issue

avatar image Seth-McCumber · Jan 26, 2014 at 02:48 PM 0
Share

Oh yeah, sorry. here

 using UnityEngine;
 using System.Collections;
 
 public class GraphicsOptionsTwo : $$anonymous$$onoBehaviour {
 
     public GUISkin Skin;
     public Player$$anonymous$$ey $$anonymous$$ey;
     public int WhatOne;
     public string[] AllTheOptions;
 
     public bool BloomEnabled = true;
     public bool LimitedFramesBool = true;
     public string BloomEnabledString;
     public string LimitedFramesString;
 
     void Start() {
         $$anonymous$$ey = GameObject.Find("$$anonymous$$eys").GetComponent<Player$$anonymous$$ey>();
     }
 
     void Update() {
         if(BloomEnabled) {
             BloomEnabledString = "Yes";
         }
         else {
             BloomEnabledString = "No";
         }
         if(LimitedFramesBool) {
             LimitedFramesString = "Yes";
         }
         else {
             LimitedFramesString = "No";
         }
         if(Input.Get$$anonymous$$eyDown($$anonymous$$ey.Down)) {    
             WhatOne++;
             if(WhatOne > 1) {
                 WhatOne = 0;
             }
         }
         if(Input.Get$$anonymous$$eyDown($$anonymous$$ey.Up)) {
             WhatOne--;
             if(WhatOne < 0) {
                 WhatOne = 1;
             }
         }
     }
 
     void OnGUI() {
         GUI.matrix = $$anonymous$$atrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3 (Screen.width / 1280.0f, Screen.height / 720.0f, 1));
         GUI.skin = Skin;
         if($$anonymous$$enuGUIHandler.Can$$anonymous$$enuHideraphics) {
             GUI.Label(new Rect(440, 50, 500, 100), "<size=30>Graphics Options</size>");
 
             GUI.SetNextControlName("BloomEnabledSwitch");
             if(GUI.Button(new Rect(476 - 100, 250, 400, 35),  "Bloom [" + BloomEnabledString + "]", "$$anonymous$$ain$$anonymous$$enuButtons")) {
                 BloomEnabled = !BloomEnabled;
                 print("WAZZUP");
                 PlayerPrefsX.SetBool("Bloom", BloomEnabled);
             }
             if(GUI.GetNameOfFocusedControl() == "BloomEnabledSwitch" && Input.Get$$anonymous$$eyDown($$anonymous$$ey.Attack)) {
                 BloomEnabled = !BloomEnabled;
                 print("WAZZUP");
                 PlayerPrefsX.SetBool("Bloom", BloomEnabled);
                }
 
                GUI.SetNextControlName("FramesEnabledSwitch");
             if(GUI.Button(new Rect(476 - 100, 350, 400, 35),  "Limited Frames [" + LimitedFramesString + "]", "$$anonymous$$ain$$anonymous$$enuButtons")) {
                 LimitedFramesBool = !LimitedFramesBool;
                 print("Im BAC$$anonymous$$!!!");
                 PlayerPrefsX.SetBool("FrameRate", LimitedFramesBool);
             }
             if(GUI.GetNameOfFocusedControl() == "FramesEnabledSwitch" && Input.Get$$anonymous$$eyDown($$anonymous$$ey.Attack)) {
                 LimitedFramesBool = !LimitedFramesBool;
                 print("Im BAC$$anonymous$$!!!");
                 PlayerPrefsX.SetBool("FrameRate", LimitedFramesBool);
                }
                if(AllTheOptions.Length > 0) {
                 GUI.FocusControl(AllTheOptions[WhatOne]);
             }
         }
     }
 }
 
avatar image Seth-McCumber · Jan 26, 2014 at 08:55 PM 0
Share

Anyone know why this is happening? Is it a bug?

avatar image Seth-McCumber · Feb 04, 2014 at 09:06 PM 0
Share

Well, bump the thread

avatar image Graham-Dunnett ♦♦ · Feb 04, 2014 at 09:25 PM 0
Share

All I can think of is that OnGUI() can be called multiple times per frame, so each event gets a chance to run. If, for bizarre reasons, your buttons get called multiple times, your inversion logic for BloomEnabled etc might not work as you expect.

Show more comments

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.

Follow this Question

Answers Answers and Comments

20 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

Related Questions

My scripts are not working properly 0 Answers

Why doesn't my if statement work? 1 Answer

Shift + KeyCode.Equals works in Unity Editor but not on WebGL build 0 Answers

Unity keeps crashing whenever I try to do anything! Please Help! 0 Answers

Why is root motion reduced once I apply the animation? 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