Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Control + Tab?

Discussion in 'Scripting' started by SparrowsNest, Jan 11, 2019.

  1. SparrowsNest

    SparrowsNest

    Joined:
    Apr 6, 2017
    Posts:
    990
    In my game i have a HUD that shows an indicator to something, and additionally it can display some details, you hit tab to toggle the display of the indicators by some rule-set, up until now I've used the shift key(+tab) to tell if the player wants to switch the detail on/off, but now the main use of the shift key is to speed up the camera movement speed so it needs to find a new home, I tried to use control( because I have a feeling alt + tab won't work very well) but it just doesn't seems to work.

    If I'm pressing tab it switches the normal mode perfectly fine, if I'm pressing control it doesn't respond at all.

    Literally all I changed was the KeyCode from Tab to LeftControl, is this some windows shortcut / unity editor shortcut?
    doesn't seems to do anything.

    *search doesn't show anything besides for stuff like xl
     
  2. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,175
    I don't think Ctrl works properly in the editor. It should work in a build.
     
  3. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,266
    It seems to me the KeyCode should still be Tab. The modifier just changed from Shift to Control. In OnGUI, just get that information from the current Event.
    Code (csharp):
    1.  
    2. Event event = Event.current;
    3. if (event.isKey && (event.type == EventType.KeyDown))
    4. {
    5.     if ((event.keyCode == KeyCode.Tab) && event.control)
    6.     {
    7.         // Tab went down while Control was held
    8.     }
    9. }
    10.  
    https://docs.unity3d.com/ScriptReference/Event.html
     
  4. SparrowsNest

    SparrowsNest

    Joined:
    Apr 6, 2017
    Posts:
    990
    I'm sorry, I meant to say i changed shift to control, tab is still in use.
    I assumed so, thanks.