Skip to content

Instantly share code, notes, and snippets.

@kxn4t
Created April 29, 2024 09:33
Show Gist options
  • Save kxn4t/dc274616b57bfe484aa1a93bed838975 to your computer and use it in GitHub Desktop.
Save kxn4t/dc274616b57bfe484aa1a93bed838975 to your computer and use it in GitHub Desktop.
GameObjectのアクティブ状態とEditorOnlyを切り替えるショートカット(Ctrl + g)
using UnityEditor;
namespace kxn4t.gist
{
internal class ToggleObjectsActive
{
[MenuItem("Tools/kxn4t gists/Toggle objects active %g")]
private static void ToggleObjectsBetweenActiveAndEditorOnly()
{
foreach (var item in Selection.transforms)
{
Undo.RecordObject (item.gameObject, "Toggle objects active");
item.gameObject.tag = item.gameObject.activeSelf ? "EditorOnly" : "Untagged";
item.gameObject.SetActive(!item.gameObject.activeSelf);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment