Skip to content

Instantly share code, notes, and snippets.

@karl-
Created April 17, 2018 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karl-/833efe87eb862fcb047e9d6c00442b8c to your computer and use it in GitHub Desktop.
Save karl-/833efe87eb862fcb047e9d6c00442b8c to your computer and use it in GitHub Desktop.
Lock and unlock the current GameObject selection.
using UnityEngine;
using UnityEditor;
static class LockObjects
{
[MenuItem("Edit/Lock Selection &l")]
static void LockSelected()
{
foreach (var o in Selection.gameObjects)
o.hideFlags = o.hideFlags | HideFlags.NotEditable;
}
[MenuItem("Edit/Unlock Selection &#l")]
static void UnlockSelected()
{
foreach (var o in Selection.gameObjects)
o.hideFlags = o.hideFlags & (~HideFlags.NotEditable);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment