How do I lock an object from selection

In other programs like Photoshop, After Effects, 3dsmax, Maya you can lock objects or layers so you don’t select them by error when working in the viewport. I want to lock my background in my 2D game.

I have tried a temporal solution to turn off the Mesh renderer from the object. (but is not exactly a lock from selection since I can’t view it anymore).

You’ve probably noticed by now, but Unity 4.3, released a couple of months after your question, added native Layer locking functionality!


There is a way to make a single object unselectable in Unity 2019.3 and newer. There is a hand icon to the left of an object in the hierarchy window. Clicking it toggles between blocking and allowing to select the object on the scene. More info at the following link, in the “Setting GameObject visibility and pickability section”:

It’s been a long time since the question has been asked. Just in case someone is still interested, there is a way to make object unselectable via click in scene. Simply add a pass with tag "LightMode" = "Picking" in your shader and discard its result instead of returning the correct _SelectionID. This is how Unity picks objects on screen fast.

        Name "Picking"
        Tags { "LightMode" = "Picking" }

            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_instancing
            #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
            #include "UnityCG.cginc"

            float4 vert(appdata_full v) : SV_POSITION
                float4 worldPos = mul(unity_ObjectToWorld, v.vertex);
                return mul(UNITY_MATRIX_VP, worldPos);

            uniform float4 _SelectionID;

            fixed4 frag() : SV_Target
                return _SelectionID;

Add this pass to your shader, your object will be unselectable in SceneView, but still selectable in hierarchy window.

There is no built-in way to do this in Unity (or at least I’m not aware of it!) but you could always script it quite easily. Here is a link to another question that pretty much solve the same thing : Lock Object Position In Editor - Unity Answers

To answer my own question: I found an utility in the Unity Asset Store that does exactly what I want. You can lock objects so you can’t edit them and also configure it in the preferences so you can’t select them in the viewport. Also is free so anyone can use it. (I’m not affiliated or know the person that made the plugin).