[Unity study notes] Some properties and functions of Sprite

Disclaimer: I am a rookie in Unity, this article is mainly used as a study note

In unity2D, each time an image resource is imported, unity will add some attributes to it, and these attributes can be viewed in the Inspector of the corresponding image resource. In unity, image resources are called sprites, which translate into Chinese as "sprites". The sprite refers to a part of the image in an integrated scene. Personally, the image resources in Unity are all part of the game scene (or the game itself). Just like sprites, they can complete human instructions and achieve some interesting Effect.

Sprite is an important basic control in unity. In unity, click on a sprite, and the properties of the selected sprite will be displayed in the Inspector.

1.Texture Type

        Texture Type, which can be translated into texture type. I personally understand it as a sprite type (not necessarily accurate). In unity2D, if you want a sprite to be captured by the camera and displayed in the game scene, you need to change the Texture Type to Sprite (2D and UI). I haven't studied the rest of the options in depth, but after changing to other Texture Types, the camera can't capture them, and the sprite pictures can't be seen even if it is set to a 3D view. (It may be necessary to add other attribute values)

         This note mainly records the properties of the sprite under the Sprite (2D and UI) type.

2.Sprite Mode

        Sprite Mode has three attribute values, which are Single, Multiply, and Polygon. If you select different attribute values, the remaining optional attributes will also be different.

        

 

 Pixels Per Unit

        Pixels Per Unit refers to the amount of pixels per unit, and the data filled in it is the pixel "side length" of the cell, that is, the length of the cell is measured in pixels. It is worth noting that after modifying the value of Pixels Per Unit, only the selected picture will change, and the grid in the scene interface will not change. For example, if the size of a picture is 16*16 pixels, after adjusting Pixels Per Unit to 16, the picture will cover exactly one cell. Similarly, if the size of a picture is 64*64 pixels, if Pixels Per Unit is set to 16 at this time, the picture will just cover 4 cells.

        In pixel games, Pixels Per Unit is often used to limit the size of each sprite image, which is more convenient and accurate than zooming in and out.

 Mesh Type

        This is related to SpriteRenderer, and it is unclear the advantages and disadvantages of the two. (However, if the project is small, the two attribute values ​​should be similar?)

Extrude Edges

        Extrude Edges uses a slider to determine the size of the area to leave around sprites in the resulting mesh. (I don’t understand it very well, I’ll take a look at it later when I encounter this thing)

Pivot        

        Pivot is the anchor point, and attributes such as the position of the sprite are set through the anchor point.

Sprite Editor

        Each sprite image has a sprite editor, and the form of the sprite editor is different according to different Texture Types. The following mainly introduces the various operations of the sprite editor under multiply. If you want to process a picture with many resources, as shown below:

         Obviously, this picture cannot be used directly. You need to change the sprite mode to multiply, and then open the sprite editor to divide this picture into multiple available resources.

        At this point, slice (cut) is available.

        

         Since what we cut is a pixel image, it should not be affected by zooming in and out. First, select the filter mode as Point (no filter), and then modify the Compression to None, that is, it will not be affected by compression. In this way, the pixel image becomes clear.

        Continue cutting:

        1. Automatic cutting

        

         Select the type in Slice as Automatic, click Slice, and get the cut picture:

        

         You can manually adjust the cut individual, and you can see the cut picture on the resource interface

         Automatic cutting is not commonly used in pixel games, and Grid by cell size and Grid by cell count are more commonly used

        2.Grid by cell size

        Cutting by cell size, since our pixel images have a fixed size, we can choose the appropriate cutting size according to each pixel image. Each cell of the pixel image used in this article is 16*16, so just adjust the Pixel Size to 16 16, so that some of the resources can be called separately.

        

 

         3.Grid by Cell count

        This cutting method is also easy to understand, that is, specify the size of the row and column, and unity will automatically cut on average. This method is often used when cutting pixel characters.

        

 

 Material link: link

        

   

Guess you like

Origin blog.csdn.net/qq_65021355/article/details/130022229