-
Layers are used to indicate some functionality
-
across many different game objects in Unity.
-
For instance, layers can be used to indicate
-
which object should be drawn in the
-
scene view, should ignore raycasts,
-
or are invisible to the camera.
-
Here we have a scene with 2 orbs in it.
-
We can see that both orbs are on the layer Default.
-
If we wanted to change the layer of 1 of the orbs
-
we could click the Layer drop-down in the inspector
-
and select a new layer.
-
We can see that this orb is now on the
-
Ignore Raycast layer
-
and will not be hit by any raycasts that pass through it.
-
We also have the ability to define our own layers.
-
We can do so using the Tag And Layer Manager window.
-
To access the tag and layer manager window
-
either select Add Layer from the Layers drop-down
-
or click Edit - Project Settings - Tags And Layers.
-
Here we can see all of the built-in layers
-
as well as add our own.
-
Let's create an Ignored By Camera layer.
-
We can place our other sphere
-
on this newly created layer
-
by selecting it and choosing the New Ignored By Camera layer
-
from the Layers drop-down.
-
This sphere is now on the
-
Ignored By Camera layer.
-
The layer has no inherent functionality however
-
so let's modify our camera to ignore it.
-
In the Culling Mask property of a camera
-
we can select which layers are seen by the camera
-
and which are not.
-
By clicking the drop-down and
-
unselecting the Ignored By Camera layer
-
all objects on that layer will no longer
-
be visible to that camera.
-
Let's run our scene.
-
We can see that only a single orb appears.
-
The other orb, the one on the Ignored By Camera Layer
-
is not rendered to the screen.
-
We can also use layers to determine
-
what appears in the scene view.
-
By clicking on the Scene Layers drop-down
-
at the top right of the Unity editor
-
we can select and deselect layers.
-
Doing so will cause all objects
-
on those layers to disappear.