- Home /
Is there a keyboard shortcut for setting an object active/inactive?
While I'm browsing the Hierarchy using the keyboard, is there a shortcut to toggle active on the selected object, or am I forced to click the inspector using the mouse?
Answer by elliselkins · Apr 17, 2015 at 12:34 AM
There is a menu item for this now. GameObject -> Toggle Active State, with shortcut Alt-Shift-A
Not sure when they removed this but you can no longer use the Alt+Shift+A hotkey anymore.
It is still there. Check in $$anonymous$$enu - GameObject, it shows as last of the drop down. You need an object to be selected for the item to be used.
I was talking about the keyboard shortcut for setting an object active/inactive. It's still missing from the latest builds.
I'm running 5.2.1 and Alt-shift-A works there.
Just to be clear, this is Edit $$anonymous$$ode, object selected in Hierarchy, then use the key shortcut; toggles the "active" box on/off. It sounds maybe like you're talking about some other use ... ?
It works on Play $$anonymous$$ode too, just tried it.
Answer by junedmmn · Feb 20, 2019 at 03:17 PM
Toggle Active/Inactive state of any selected Game object in Unity Hierarchy use Alt + Shift + A. Its working in Unity Version 2018.3.0f2.
Answer by Aram-Azhari · Oct 30, 2013 at 10:20 AM
There are no shortcuts that I know of. However, Similar to Customize shortcuts in the unity-editor, you can create a menu item with a shortcut that does this for you.
Create a folder called Editor and inside of it, create a c# script and name it MyShortcuts.cs and paste this in:
using UnityEditor;
using UnityEngine;
public class MyShortcuts : Editor
{
[MenuItem("GameObject/ActiveToggle _a")]
static void ToggleActivationSelection()
{
var go = Selection.activeGameObject;
go.SetActive(!go.activeSelf);
}
}
Now whenever you select an object if you press "a", it activates/deactivates it. Note that the caps lock should be on. I couldn't figure out why it needs it to be caps lock, but it does work :)
I hope this answers your question.
Thanks for this Aram. A useful modification is to toggle the state of all selected objects, replacing lines 9 and 10 with:
foreach(GameObject go in Selection.gameObjects)
go.SetActive(!go.activeSelf);
This works brilliantly, thanks a lot! Just a note to others, the Editor folder can just be placed in the Assets folder (there will probably already be one there, there was for me).
When I'm typing text into the Text UI component in Unity the 'A' key gets consumed now and I have to edit this script every time I want to type the letter 'a' somewhere.
I tried using elliselkins's method and it works for me. Although I've only tested it on $$anonymous$$ac (using Right-Option + Right-Shift + a).
You can modify the _a part in line 6 of my code to something else that isn't used. Refer to $$anonymous$$enuItem on how to modify that to your liking.