< Return to Video

Sprite Renderer - Official Unity Tutorial

  • 0:01 - 0:04
    The sprite renderer component displays images
  • 0:04 - 0:06
    that have been imported as the sprite type
  • 0:06 - 0:09
    for use in both 2D and 3D scenes.
  • 0:10 - 0:12
    The primary property of the sprite
  • 0:12 - 0:14
    renderer is sprite.
  • 0:16 - 0:18
    This is a reference to the sprite to render.
  • 0:20 - 0:23
    For more information on the sprite import type
  • 0:23 - 0:25
    please see the information linked below.
  • 0:27 - 0:30
    Colour is the vertex colour of the rendered sprite
  • 0:30 - 0:32
    and can be used to tint or recolour
  • 0:32 - 0:33
    the sprite image.
  • 0:35 - 0:37
    Colour can also be used to fade the
  • 0:37 - 0:39
    sprite's opacity by changing the value
  • 0:39 - 0:41
    of the colour's alpha channel.
  • 0:43 - 0:45
    The sprite's colour property is independent
  • 0:45 - 0:48
    of the sprite's material, so changing the colour
  • 0:48 - 0:50
    property on a sprite will only effect
  • 0:50 - 0:52
    that particular game object.
  • 0:54 - 0:56
    Material is a reference to the material
  • 0:56 - 0:58
    used to render the sprite.
  • 0:59 - 1:02
    By default a new sprite renderer component
  • 1:02 - 1:05
    will have the material sprite's default assigned.
  • 1:06 - 1:09
    When using this default material the sprite will not
  • 1:09 - 1:11
    be effected by any lighting in the scene.
  • 1:12 - 1:14
    The sprite renderer will simply render the
  • 1:14 - 1:16
    original sprite at full brightness.
  • 1:17 - 1:20
    In many cases lighting is not necessary
  • 1:20 - 1:22
    when creating a 2D game.
  • 1:22 - 1:24
    To use lights with a sprite renderer
  • 1:24 - 1:26
    a material with a shader that responds
  • 1:26 - 1:28
    to lighting must be selected.
  • 1:29 - 1:33
    Sprites Diffuse is optimised for use with sprites,
    33Diffuse
    00:01:32,577 --> 00:01:35,071
    but many other shaders can be used.
  • 1:40 - 1:43
    Due to the nature of shaders, and the sprite renderer,
  • 1:43 - 1:46
    some shaders are incompatible with the sprite renderer.
  • 1:48 - 1:51
    Sprites use standard Unity materials,
  • 1:51 - 1:53
    however, the sprite renderer handles
  • 1:53 - 1:56
    materials differently than the mesh renderer.
  • 1:56 - 1:58
    The main difference is that the material's
  • 1:58 - 2:00
    texture property is not needed.
  • 2:01 - 2:04
    The sprite renderer will use the shader,
  • 2:04 - 2:07
    colour and other properties from a compatible material
  • 2:07 - 2:09
    but not the texture property.
  • 2:11 - 2:14
    When using a material that has a sprite shader
  • 2:15 - 2:18
    the texture property is unavailable.
  • 2:20 - 2:23
    If the attached material has a tint colour
  • 2:23 - 2:26
    it will be combined with the sprite's colour property.
  • 2:33 - 2:37
    It is important to note that lighting and shadow.
  • 2:37 - 2:40
    So when using lights and more complex shaders
  • 2:40 - 2:44
    it is best to balance the lighting with the performance of the scene.
  • 2:45 - 2:48
    For more information on materials and shaders,
  • 2:48 - 2:50
    please see the information linked below.
  • 2:53 - 2:55
    Sorting Layer and Order In Layer are
  • 2:55 - 2:57
    the systems used to define the order
  • 2:57 - 2:59
    in which sprites are drawn.
  • 3:00 - 3:03
    All sprite renderers are placed on a default
  • 3:03 - 3:05
    sorting layer when they are created.
  • 3:06 - 3:08
    Sprites are rendered by the sprite render
  • 3:08 - 3:10
    in the following order of priority.
  • 3:11 - 3:14
    The order of the sorting layer, containing the sprite,
  • 3:16 - 3:18
    the order in layer value for the sprite
  • 3:18 - 3:20
    within that sorting layer
  • 3:22 - 3:24
    and finally the sprite's transform position
  • 3:24 - 3:27
    Z compared to the other sprites being rendered
  • 3:27 - 3:29
    and the camera rendering them.
  • 3:30 - 3:33
    In the case of sorting layers and order-in-layer
  • 3:33 - 3:35
    items with lower values will be
  • 3:35 - 3:37
    behind those with higher values.
  • 3:37 - 3:40
    For more information on layers, including sorting layers,
  • 3:40 - 3:43
    please see the information linked below.
Title:
Sprite Renderer - Official Unity Tutorial
Description:

more » « less
Duration:
03:44

English subtitles

Revisions