< Return to Video

Layers - Official Unity Tutorial

  • 0:00 - 0:03
    Layers are used to indicate some functionality
  • 0:03 - 0:06
    across many different game objects in Unity.
  • 0:06 - 0:10
    For instance, layers can be used to indicate
  • 0:10 - 0:12
    which object should be drawn in the
  • 0:12 - 0:14
    scene view, should ignore raycasts,
  • 0:14 - 0:17
    or are invisible to the camera.
  • 0:18 - 0:21
    Here we have a scene with 2 orbs in it.
  • 0:21 - 0:25
    We can see that both orbs are on the layer Default.
  • 0:27 - 0:30
    If we wanted to change the layer of 1 of the orbs
  • 0:30 - 0:33
    we could click the Layer drop-down in the inspector
  • 0:33 - 0:35
    and select a new layer.
  • 0:35 - 0:38
    We can see that this orb is now on the
  • 0:38 - 0:40
    Ignore Raycast layer
  • 0:40 - 0:43
    and will not be hit by any raycasts that pass through it.
  • 0:45 - 0:48
    We also have the ability to define our own layers.
  • 0:48 - 0:52
    We can do so using the Tag And Layer Manager window.
  • 0:53 - 0:56
    To access the tag and layer manager window
  • 0:56 - 1:00
    either select Add Layer from the Layers drop-down
  • 1:01 - 1:06
    or click Edit - Project Settings - Tags And Layers.
  • 1:08 - 1:10
    Here we can see all of the built-in layers
  • 1:10 - 1:12
    as well as add our own.
  • 1:13 - 1:17
    Let's create an Ignored By Camera layer.
  • 1:18 - 1:20
    We can place our other sphere
  • 1:20 - 1:22
    on this newly created layer
  • 1:22 - 1:28
    by selecting it and choosing the New Ignored By Camera layer
  • 1:28 - 1:30
    from the Layers drop-down.
  • 1:31 - 1:33
    This sphere is now on the
  • 1:33 - 1:35
    Ignored By Camera layer.
  • 1:36 - 1:39
    The layer has no inherent functionality however
  • 1:39 - 1:42
    so let's modify our camera to ignore it.
  • 1:44 - 1:47
    In the Culling Mask property of a camera
  • 1:47 - 1:50
    we can select which layers are seen by the camera
  • 1:50 - 1:52
    and which are not.
  • 1:53 - 1:55
    By clicking the drop-down and
  • 1:55 - 1:58
    unselecting the Ignored By Camera layer
  • 1:58 - 2:00
    all objects on that layer will no longer
  • 2:00 - 2:03
    be visible to that camera.
  • 2:04 - 2:06
    Let's run our scene.
  • 2:06 - 2:09
    We can see that only a single orb appears.
  • 2:10 - 2:14
    The other orb, the one on the Ignored By Camera Layer
  • 2:14 - 2:16
    is not rendered to the screen.
  • 2:17 - 2:19
    We can also use layers to determine
  • 2:19 - 2:22
    what appears in the scene view.
  • 2:23 - 2:25
    By clicking on the Scene Layers drop-down
  • 2:25 - 2:28
    at the top right of the Unity editor
  • 2:28 - 2:31
    we can select and deselect layers.
  • 2:32 - 2:34
    Doing so will cause all objects
  • 2:34 - 2:37
    on those layers to disappear.
Title:
Layers - Official Unity Tutorial
Description:

more » « less
Duration:
02:39

English subtitles

Revisions