The sprite renderer component displays images
that have been imported as the sprite type
for use in both 2D and 3D scenes.
The primary property of the sprite
renderer is sprite.
This is a reference to the sprite to render.
For more information on the sprite import type
please see the information linked below.
Colour is the vertex colour of the rendered sprite
and can be used to tint or recolour
the sprite image.
Colour can also be used to fade the
sprite's opacity by changing the value
of the colour's alpha channel.
The sprite's colour property is independent
of the sprite's material, so changing the colour
property on a sprite will only effect
that particular game object.
Material is a reference to the material
used to render the sprite.
By default a new sprite renderer component
will have the material sprite's default assigned.
When using this default material the sprite will not
be effected by any lighting in the scene.
The sprite renderer will simply render the
original sprite at full brightness.
In many cases lighting is not necessary
when creating a 2D game.
To use lights with a sprite renderer
a material with a shader that responds
to lighting must be selected.
Sprites Diffuse is optimised for use with sprites,
33Diffuse
00:01:32,577 --> 00:01:35,071
but many other shaders can be used.
Due to the nature of shaders, and the sprite renderer,
some shaders are incompatible with the sprite renderer.
Sprites use standard Unity materials,
however, the sprite renderer handles
materials differently than the mesh renderer.
The main difference is that the material's
texture property is not needed.
The sprite renderer will use the shader,
colour and other properties from a compatible material
but not the texture property.
When using a material that has a sprite shader
the texture property is unavailable.
If the attached material has a tint colour
it will be combined with the sprite's colour property.
It is important to note that lighting and shadow.
So when using lights and more complex shaders
it is best to balance the lighting with the performance of the scene.
For more information on materials and shaders,
please see the information linked below.
Sorting Layer and Order In Layer are
the systems used to define the order
in which sprites are drawn.
All sprite renderers are placed on a default
sorting layer when they are created.
Sprites are rendered by the sprite render
in the following order of priority.
The order of the sorting layer, containing the sprite,
the order in layer value for the sprite
within that sorting layer
and finally the sprite's transform position
Z compared to the other sprites being rendered
and the camera rendering them.
In the case of sorting layers and order-in-layer
items with lower values will be
behind those with higher values.
For more information on layers, including sorting layers,
please see the information linked below.