Search Issue Tracker

Postponed means that the issue was either a feature request or something that requires major refactoring on our side. Since that makes the issue not actionable in the close future we choose to close it as Postponed and add it on our internal roadmaps and technical debt pages instead.

Postponed

Votes

45

Found in

4.0.0b11

Issue ID

511758

Regression

No

Disable editor keyboard shortcuts while playing

Input

-

Steps to reproduce :

- create a new project
- press play and press ctrl+s, notice the message in the console complaining that you can't save the scene while in play mode

Request :
Editor shortcuts should be disabled when in playmode.

Comments (54)

  1. Aca70a181e69ca78e53d57a1c3c9527b?d=mm

    martybalandis

    Aug 11, 2019 22:30

    @NSXDAVID Solution works but it then takes ages (noticeable amount) to load a game when pressing "Play". Clever solution though, maybe there is a way to optimise it to not affect the loading times?

  2. E54b7af50717acc5a97fd83cf2b1cb00?d=mm

    nsxdavid

    Aug 02, 2019 16:00

    Fellow Unity Enthusiasts (who are not understanding how this has not been fixed in all this time)...

    Here is a work around that will save your sanity. Drop this script in an Editor folder somewhere in your project and all your worries are over. It's that simple:

    using UnityEngine;
    using UnityEditor;
    using UnityEditor.ShortcutManagement;
    using System;

    [InitializeOnLoadAttribute]
    public class DisableEditorShortcutsOnPlay
    {
    private const string emptyProfile = "An Empty Profile";

    // register an event handler when the class is initialized
    static DisableEditorShortcutsOnPlay()
    {
    EditorApplication.playModeStateChanged += DetectPlayModeState;
    }

    private static void CreateEmptyProfile()
    {
    try
    {
    ShortcutManager.instance.CreateProfile(emptyProfile);
    }
    catch (Exception)
    {
    // Already existed, so... we good
    }

    ShortcutManager.instance.activeProfileId = emptyProfile;
    foreach (var pid in ShortcutManager.instance.GetAvailableShortcutIds())
    ShortcutManager.instance.RebindShortcut(pid, ShortcutBinding.empty);
    ShortcutManager.instance.activeProfileId = ShortcutManager.defaultProfileId;
    }

    private static void DeleteEmptyProfile()
    {
    ShortcutManager.instance.DeleteProfile(emptyProfile);
    }

    private static void DetectPlayModeState(PlayModeStateChange state)
    {
    Debug.Log(state);
    if (state == PlayModeStateChange.EnteredPlayMode)
    {
    CreateEmptyProfile();
    ShortcutManager.instance.activeProfileId = emptyProfile;
    }
    else
    if (state == PlayModeStateChange.ExitingPlayMode) {
    ShortcutManager.instance.activeProfileId = ShortcutManager.defaultProfileId;
    DeleteEmptyProfile();
    }

    }

    }

    When you go into play mode this creates a new shortcut profile, overrides all the bindings to empty, and sets that as the active profile. On stop play, it reverts back to the active profile and deletes the temporary one.

    Now with this madness behind us, let's go create aweomsesauce!

  3. 9d4bd236d332dd88c5f1f215be52916e?d=mm

    Zahidylin_Marat

    Jul 31, 2019 15:15

    Editor shortcuts should be disabled when in playmode.

  4. 99ea119b7f81ed97b53c7c76ddd50fcd?d=mm

    patrik-org

    Jul 28, 2019 10:00

    I'm creating an in-game editor with and I need to capture CTRL+s, CTRL+z, etc. Using other shortcuts while in the editor does not work as it's meant to be used in the editor and expecting the user to use other keyboard shortcuts is not an acceptable. I just need a simple way to disable editor keyboard shortcuts while playing. Something like:

    EditorApplication.disableKeyboardShortcutsWhilePlaying = true;

  5. Bacfccdec205e87dc1e7fca80a9e5f3e?d=mm

    Zacryon

    Jun 29, 2019 12:03

    Still a problem in summer of 2019...

  6. 21b81ace1352b0e7c9f40d54dbfa4142?d=mm

    jonathan-rendon

    Jun 27, 2019 10:55

    I just found a temporary fix. I only need to unmerge the Game window from the editor, and the Alt key is free, even Alt-F4.

  7. Df3e089863ce6d9bd694346a47081ba7?d=mm

    Ptiteigne

    Jun 13, 2019 12:05

    The workaround found by @Bardian25 is functional but so tedious.

    However, there is no doubt that it would be really easy to automatize the same process as the one in the workaround.

  8. 52fe27537ed926494493de9d30a736c3?d=mm

    Bardian25

    Apr 28, 2019 05:58

    Correction to my previous comment: This method does not work with combinations involving alt, as pressing alt will still que selection of the menu tab with certain keys. There may be other exceptions, my apologies.

  9. 52fe27537ed926494493de9d30a736c3?d=mm

    Bardian25

    Apr 28, 2019 05:50

    Workaround for anyone who needs it:

    1. Open the "Edit" menu, select "Shortcuts...", this will open the window for editing the in-editor keyboard shortcuts.
    2. Use the drop-down tab in the upper left corner of the shortcuts window to make a new profile in case you actually want default shortcuts for something later.
    3. Disable or reassign problematic shortcuts

    Scrolling through the command list can be quite tedious but if you are just getting rid of a shortcut you need only to right click on the key on the virtual keyboard, highlight the function you wish to remove, and select the "Remove Shortcut" pop-out.

    Shortcuts involving combos with shift, alt, or ctrl can be accessed the same way, by highlighting whichever of those keys is in the shortcut with a left click on the virtual keyboard, than right clicking on the other key in the combination and proceeding with the removal of the shortcut.

    Will be great if the conflicts are handled automatically someday, but in the mean time I hope this helps.

  10. 3397e68ad576561a47b6817e99101b13?d=mm

    QuincyC

    Apr 10, 2019 19:44

    This introduces totally random errors to my in-game undo system which uses ctrl-z and ctrl-y... because the object hierarchy gets DESTROYED when I use it. Totally annoying, totally unacceptable. This is a NEEDED feature

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.