1 00:00:01,160 --> 00:00:03,819 The sprite renderer component displays images 2 00:00:03,819 --> 00:00:06,383 that have been imported as the sprite type 3 00:00:06,383 --> 00:00:09,412 for use in both 2D and 3D scenes. 4 00:00:10,112 --> 00:00:12,140 The primary property of the sprite 5 00:00:12,140 --> 00:00:14,140 renderer is sprite. 6 00:00:15,648 --> 00:00:18,390 This is a reference to the sprite to render. 7 00:00:20,216 --> 00:00:22,649 For more information on the sprite import type 8 00:00:22,649 --> 00:00:25,136 please see the information linked below. 9 00:00:26,820 --> 00:00:29,805 Colour is the vertex colour of the rendered sprite 10 00:00:29,805 --> 00:00:31,805 and can be used to tint or recolour 11 00:00:31,805 --> 00:00:33,266 the sprite image. 12 00:00:35,009 --> 00:00:37,009 Colour can also be used to fade the 13 00:00:37,009 --> 00:00:39,009 sprite's opacity by changing the value 14 00:00:39,009 --> 00:00:41,009 of the colour's alpha channel. 15 00:00:42,738 --> 00:00:44,738 The sprite's colour property is independent 16 00:00:44,738 --> 00:00:47,866 of the sprite's material, so changing the colour 17 00:00:47,866 --> 00:00:49,866 property on a sprite will only effect 18 00:00:49,866 --> 00:00:51,866 that particular game object. 19 00:00:53,678 --> 00:00:55,678 Material is a reference to the material 20 00:00:55,678 --> 00:00:57,915 used to render the sprite. 21 00:00:59,034 --> 00:01:01,546 By default a new sprite renderer component 22 00:01:01,546 --> 00:01:04,831 will have the material sprite's default assigned. 23 00:01:06,049 --> 00:01:08,757 When using this default material the sprite will not 24 00:01:08,757 --> 00:01:11,299 be effected by any lighting in the scene. 25 00:01:12,030 --> 00:01:14,030 The sprite renderer will simply render the 26 00:01:14,030 --> 00:01:16,414 original sprite at full brightness. 27 00:01:17,234 --> 00:01:19,798 In many cases lighting is not necessary 28 00:01:19,798 --> 00:01:21,798 when creating a 2D game. 29 00:01:22,381 --> 00:01:24,381 To use lights with a sprite renderer 30 00:01:24,381 --> 00:01:26,381 a material with a shader that responds 31 00:01:26,381 --> 00:01:28,381 to lighting must be selected. 32 00:01:28,922 --> 00:01:32,577 Sprites Diffuse is optimised for use with sprites, 33 00:01:32,577 --> 00:01:35,071 but many other shaders can be used. 34 00:01:40,353 --> 00:01:43,025 Due to the nature of shaders, and the sprite renderer, 35 00:01:43,025 --> 00:01:46,203 some shaders are incompatible with the sprite renderer. 36 00:01:47,905 --> 00:01:50,501 Sprites use standard Unity materials, 37 00:01:50,501 --> 00:01:52,501 however, the sprite renderer handles 38 00:01:52,501 --> 00:01:55,537 materials differently than the mesh renderer. 39 00:01:56,465 --> 00:01:58,465 The main difference is that the material's 40 00:01:58,465 --> 00:02:00,465 texture property is not needed. 41 00:02:01,393 --> 00:02:03,780 The sprite renderer will use the shader, 42 00:02:03,780 --> 00:02:07,078 colour and other properties from a compatible material 43 00:02:07,078 --> 00:02:09,078 but not the texture property. 44 00:02:11,028 --> 00:02:14,396 When using a material that has a sprite shader 45 00:02:15,117 --> 00:02:17,766 the texture property is unavailable. 46 00:02:20,462 --> 00:02:22,930 If the attached material has a tint colour 47 00:02:22,930 --> 00:02:25,807 it will be combined with the sprite's colour property. 48 00:02:33,102 --> 00:02:37,206 It is important to note that lighting and shadow. 49 00:02:37,206 --> 00:02:40,169 So when using lights and more complex shaders 50 00:02:40,169 --> 00:02:44,053 it is best to balance the lighting with the performance of the scene. 51 00:02:44,912 --> 00:02:47,617 For more information on materials and shaders, 52 00:02:47,617 --> 00:02:50,107 please see the information linked below. 53 00:02:52,783 --> 00:02:54,783 Sorting Layer and Order In Layer are 54 00:02:54,783 --> 00:02:56,783 the systems used to define the order 55 00:02:56,783 --> 00:02:58,783 in which sprites are drawn. 56 00:03:00,443 --> 00:03:02,568 All sprite renderers are placed on a default 57 00:03:02,568 --> 00:03:04,568 sorting layer when they are created. 58 00:03:05,800 --> 00:03:08,171 Sprites are rendered by the sprite render 59 00:03:08,171 --> 00:03:10,171 in the following order of priority. 60 00:03:11,127 --> 00:03:14,391 The order of the sorting layer, containing the sprite, 61 00:03:16,106 --> 00:03:18,106 the order in layer value for the sprite 62 00:03:18,106 --> 00:03:20,106 within that sorting layer 63 00:03:22,277 --> 00:03:24,277 and finally the sprite's transform position 64 00:03:24,277 --> 00:03:26,875 Z compared to the other sprites being rendered 65 00:03:26,875 --> 00:03:28,875 and the camera rendering them. 66 00:03:29,776 --> 00:03:32,549 In the case of sorting layers and order-in-layer 67 00:03:32,549 --> 00:03:34,549 items with lower values will be 68 00:03:34,549 --> 00:03:36,731 behind those with higher values. 69 00:03:37,477 --> 00:03:40,499 For more information on layers, including sorting layers, 70 00:03:40,499 --> 00:03:42,943 please see the information linked below.