Skip to content

Instantly share code, notes, and snippets.

@omid3098
Created February 3, 2022 16:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omid3098/6381c70bb36184f9e2234c2a42eba9ad to your computer and use it in GitHub Desktop.
Save omid3098/6381c70bb36184f9e2234c2a42eba9ad to your computer and use it in GitHub Desktop.
A tiny little editor window to switch objects activation state
/*
Copyright (c) 2022 Omid Saadat
Licensed under the MIT License (Do whatevever you want with this!);
*/
using UnityEngine;
using UnityEditor;
public class ObjectActivationSwitch : EditorWindow
{
[MenuItem("LeMoonade/ObjectActivationSwitch")]
private static void ShowWindow()
{
var window = GetWindow<ObjectActivationSwitch>();
window.titleContent = new GUIContent("ObjectActivationSwitch");
window.Show();
}
private void OnGUI()
{
if (GUILayout.Button("Switch Objects"))
{
SwitchObjects();
}
}
private void SwitchObjects()
{
var currentSelection = Selection.gameObjects;
if (currentSelection != null && currentSelection.Length > 0)
{
foreach (var obj in currentSelection)
{
obj.SetActive(!obj.activeSelf);
}
}
}
}
@omid3098
Copy link
Author

omid3098 commented Feb 3, 2022

Go to LeMoonade menu, and select ObjectActivationSwitch
Preview:
GIF 2-3-2022 6-41-55 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment