Last active
October 23, 2021 12:04
-
-
Save Democide/aa9654d742394f2920beaa94cece3cbd to your computer and use it in GitHub Desktop.
Simple Unity script to toggle the activation state of selected game objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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