Created
February 3, 2022 16:25
-
-
Save omid3098/6381c70bb36184f9e2234c2a42eba9ad to your computer and use it in GitHub Desktop.
A tiny little editor window to switch objects activation state
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
/* | |
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); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go to LeMoonade menu, and select ObjectActivationSwitch
Preview: