Skip to content

Instantly share code, notes, and snippets.

@Minimally
Last active August 23, 2018 20:58
Show Gist options
  • Save Minimally/11071838 to your computer and use it in GitHub Desktop.
Save Minimally/11071838 to your computer and use it in GitHub Desktop.
Unity3d class to quickly set GameObjects active/inactive with s and h
using System.Collections;
using UnityEditor;
using UnityEngine;
public static class ActiveMenu
{
/* PLACE IN EDITOR FOLDER.
* Feel free to change hotkeys depending on your preference.
* Modifier Keys % (ctrl on Windows, cmd on OS X), # (shift), & (alt), _ (no key modifiers) */
#region GameObject Active
[MenuItem("Edit/Selection/Set Active _s", false)]
static void ToggleActive()
{
foreach (Transform item in Selection.transforms)
{
item.gameObject.SetActive(true);
}
}
[MenuItem("Edit/Selection/Set Active _s", true)]
static bool ValidateToggleActive()
{
// Return false if no transform is selected.
return !(Selection.transforms == null || Selection.transforms.Length == 0);
}
[MenuItem("Edit/Selection/Set Inactive _h", false)]
static void ToggleInactive()
{
foreach (Transform item in Selection.transforms)
{
item.gameObject.SetActive(false);
}
}
[MenuItem("Edit/Selection/Set Inactive _h", true)]
static bool ValidateToggleInactive()
{
// Return false if no transform is selected.
return !(Selection.transforms == null || Selection.transforms.Length == 0);
}
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment