culling & layers confusion

If make a custom layer and I make an object be that layer then I can set the camera to Culling Mask that layer, and it wont show up.

in the docs it says:

// Only render objects in the first layer (Default layer) camera.cullingMask = 1 << 0;

What are the layer numbers? what does << mean? less than 1? why two '<''s

What script would I need to be able to press a key and hide say stuff that was on one of my custom layers?

thanks

First, read up on Bitshift Operators.

Then, read the Layers page in the Unity docs, that explains how to select different layers.

In your case, you would want to do something like this, if your object was on User layer 8:

Camera.main.cullingMask = ~(1 << 8);

Because 8 is the layer mask your "selective" object is on, and the ~ operator reverses all bits, specifying "all but this layer".

And to reset it to render everything:

Camera.main.cullingMask = ~(0);

Edit:

Since you finally described what you wanted, after an incredibly large amount of comments, this will work if you stick it in Update somewhere. Fill in however many layers you want.

if(Input.GetKeyDown(KeyCode.Alpha1))
{
     Camera.main.cullingMask = 1 | 1 << 8;
}
else if(Input.GetKeyDown(KeyCode.Alpha2))
{
    Camera.main.cullingMask = 1 | 1 << 9; 
}
else if // etc ...

This wouldn't so much HIDE stuff on a custom layer but doing something like the following can set it to cull at certain distances taken from: Camera.layerCullDistance page. If, like me, you were just looking to hide things after a certain distance this is much easier. I had been juggling layers in the same way, this is a much cleaner approach to what I was looking for. Hope it helps, if not there are plenty of good suggestions up top.

function Start  ()
{
var distances = new float[32];
// Set up layer 10 to cull at 15 meters distance.
// All other layers use the far clip plane distance.
distances[10] = 15;
camera.layerCullDistances = distances;
}