Skip to content

Instantly share code, notes, and snippets.

@Democide
Last active October 23, 2021 12:04
Show Gist options
  • Save Democide/aa9654d742394f2920beaa94cece3cbd to your computer and use it in GitHub Desktop.
Save Democide/aa9654d742394f2920beaa94cece3cbd to your computer and use it in GitHub Desktop.
Simple Unity script to toggle the activation state of selected game objects
using UnityEngine;
using System.Collections;
using UnityEditor;
public static class ShortcutToggleObjectActivation
{
// LEFT ALT + LEFT SHIFT + A to toggle active state of selected GameObjects
[MenuItem("Shortcuts/Toggle Selected GameObjects Active #&a")]
static void SaveGameOpenFolder()
{
if (Selection.gameObjects.Length > 1) {
foreach (var item in Selection.gameObjects) {
item.SetActive(!item.activeSelf);
}
}
else if (Selection.activeGameObject != null) {
Selection.activeGameObject.SetActive(!Selection.activeGameObject.activeSelf);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment