Как сделать тайлсет для unity
Creating Tilemaps
A Tilemap is a GameObject you place your selected Tiles on. Create a default (rectangular) Tilemap A GameObject that allows you to quickly create 2D levels using tiles and a grid overlay. More info
See in Glossary by going to GameObject > 2D Object > Tilemap. If you do not have these options, then the 2D Tilemap Editor package may not be installed. If so, download the 2D Tilemap Editor package from the Package Manager.
Select the ‘Tilemap’ option to create the default rectangular Tilemap. Refer to the respective pages for Hexagonal and Isometric Tilemaps for more information on their uses and their options.
The child Tilemap is comprised of a Tilemap component and Tilemap Renderer component. The Tilemap GameObject is where the Tiles are painted on.
Create additional Tilemaps by selecting the Grid GameObject or the Tilemap GameObject, and then go to the menu: GameObject The fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary > 2D Object A 2D GameObject such as a tilemap or sprite. More info
See in Glossary > Tilemaps, or right-click on the selected GameObject and go to 2D Object > Tilemap to add another Tilemap as a child to the same parent Grid.
Once the Tilemap(s) are created, adjust the Grid property settings to adjust the properties of its Tilemap children, such as Cell Size or the type of layout of the child Tilemaps. These also affects attached components such as the Tilemap Renderer and Tilemap Collider 2D components.
Tilemap
The Tilemap component is a system which stores and handles Tile Assets for creating 2D levels. It transfers the required information from the Tiles placed on it to other related components such as the Tilemap Renderer and the Tilemap Collider 2D
Download the 2D Tilemap Editor package via the Package Manager, as it is not included in the Unity Editor default installation.
When you create a Tilemap, the Grid component is automatically parented to the Tilemap and acts as a guide when you lay out Tiles onto the Tilemap.
To create, modify, and pick the Tiles for painting onto a Tilemap, use the Tile Palette (menu: Window > 2D > Tile Palette) and its tools. Refer to the documentation on Tile Palette and Painting Tilemaps for more information.
Tilemap property window
Property | Function |
---|---|
Animation Frame Rate | The rate at which Unity plays Tile animations. Increasing or decreasing this changes the speed by the equivalent factor (for example, if you set this to 2, Unity plays Tile animations at double the speed). |
Color | Select a color to apply as a tint to the Tiles on this Tilemap. Set to white (default color) to have Unity render the Tiles without tint. |
Tile Anchor | Enter the amount (in cells) along the XYZ axes to offset Tile anchor positions on the Tilemap. |
Orientation | Select the orientation of Tiles on the Tilemap. Use this if you need to orientate Tiles along a specific plane. |
XY | Unity orients Tiles along the XY plane. |
XZ | Unity orients Tiles along the XZ plane. |
YX | Unity orients Tiles along the YX plane. |
YZ | Unity orients Tiles along the YZ plane. |
ZX | Unity orients Tiles along the ZX plane. |
ZY | Unity orients Tiles along the ZY plane. |
Custom | Select this option to enable the custom orientation settings below. |
Position | Set the position offset of the custom orientation. This option is disabled by default and is enabled when the Tilemap’s Orientation is set to Custom. |
Rotation | Set the rotation of the custom orientation. This option is disabled by default and is enabled when the Tilemap’s Orientation is set to Custom. |
Scale | Set the scale of the custom orientation. This option is disabled by default and is enabled when the Tilemap’s Orientation is set to Custom. |
2D extras in GitHub
You can download examples of scripted Tiles A simple class that allows a sprite to be rendered on a Tilemap. More info
See in Glossary and Brushes from the 2D Extra GitHub repository. Example projects with these scripted GameObjects The fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary are available in the 2D Techdemos Github repository. For descriptions of the different scripts A piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary and usage information, refer to the README.md for each repository.
Tile Palette
Create Palettes with selected Tiles in the Tile Palette window, which are used to paint on Tilemaps. Open the Tile Palette window from the menu: Window > 2D > Tile Palette.
Create a new Palette by selecting Create New Palette.
Create New Palette button
In the Create New Palette window are the following options.
Свойство: | Функция: |
---|---|
Name | Provide a name for the created Tile Palette Asset. |
Grid | Select the Grid layout the created Tile Palette will be used to paint on. |
Rectangle | Select this if creating a Palette for the default rectangular Tilemap. |
Hexagon | Select this when creating a Palette for a Hexagonal Tilemap. |
Isometric | Select this when creating a Palette for a Isometric Tilemap. Refer to Creating a Tile Palette for an Isometric Tilemap for more information. |
Isometric Z as Y | Select this when creating a Palette for a Isometric Z as Y Tilemap. Refer to Creating a Tile Palette for an Isometric Tilemap for more information. |
* Hexagon Type (only available when the Hexagon Grid type is selected) | Select the type of Hexagonal Tilemap that the Palette will be used to paint on. Refer to the documentation on Hexagonal Tilemaps for more information. |
Cell Size | The size of a cell that the Tiles are painted on. |
Automatic | The Cell Size is automatically set in Unity units and based on the size of the Sprite used to create the Tile Assets. If there are multiple Tiles, the Cell Size is adjusted to match the first Tile from the bottom left of the Palette, so that it fits exactly on a cell. |
Manual | Select this option to input custom size values. |
Provide a name for the Palette and select the Create button. Select a folder to save the Palette. The newly created Palette is automatically loaded.
Blank Tile Palette
Drag and drop Textures or Sprites from the Assets folder onto the Tile Palette. Choose where to save the new Tile Assets. New Tile Assets are generated in the selected folder and the Tiles are placed on the Tile Palette.
Use the following shortcuts to navigate the Palette window.
Shortcut | Функция: |
---|---|
Click a Tile | Selects the Tile |
Drag over multiple Tiles | Selects multiple Tiles |
Alt + Left button drag | Pan (перемещение камеры сцены) |
Wheel button drag | Pan (перемещение камеры сцены) |
Rotate the wheel button | Zoom in/out |
Z Position Editor
At the bottom of the Tile Palette window is the Z Position brush editor. This allows the editing of the Z-axis values of Tiles, which can be used to adjust Tile heights when painting on a Z as Y Tilemap. Refer to the documentation on Adjusting the Tile height in the Palette for more information.
Editing the Tile Palette
The Palette tools used to paint Tiles onto Tilemaps can also be used to edit the placement of Tiles in the Palette itself. Select a Palette from the drop-down menu, then click Edit to unlock the Palette for editing.
Refer to the documentation on Painting on Tilemaps for the shortcuts and functions of the Palette tools which can also be used to edit the Palette.
Tilemap
The Tilemap component is a system which stores and handles Tile Assets for creating 2D levels. It transfers the required information from the Tiles placed on it to other related components such as the Tilemap Renderer and the Tilemap Collider 2D.
Use this component with the Grid component, or a parent Grid GameObject, to lay out Tiles on the associated Grid. When creating a Tilemap (menu: GameObject > 2D Object > Tilemap), Unity automatically creates a Grid GameObject and sets it as the parent of a child Tilemap GameObject.
To modify and place Tiles onto a Tilemap, open the Tile Palette (menu: Window > 2D > Tile Palette). Refer to the documentation on Tile Palette and Painting Tilemaps for more information.
Tilemap property window
Свойство: | Функция: |
---|---|
Animation Frame Rate | The rate at which Unity plays Tile animations. Increasing or decreasing this changes the speed by the equivalent factor (for example, if you set this to 2, Unity plays Tile animations at double the speed). |
Color | Tints the Tiles on this Tilemap with the selected Color. When set to white, Unity renders the Tiles with no tint. |
Tile Anchor | The anchoring offset of a Tile on this Tilemap. Adjust the position values to offset the cell position of the Tile on the associated Grid. |
Идентификация | The orientation of Tiles on the Tilemap. Use this if you need to orientate Tiles on a specific plane (particularly in a 3D view). |
XY | Unity orients tiles on the XY plane. |
XZ | Unity orients tiles on the XZ plane. |
YX | Unity orients tiles on the YX plane. |
YZ | Unity orients tiles on the YZ plane. |
ZX | Unity orients tiles on the ZX plane. |
ZY | Unity orients tiles on the ZY plane. |
Custom | Unity lays out tiles based on the custom orientation matrix settings set by the parameters below, which become editable when you select this option. |
Position | Displays the position offset of the current orientation matrix. You can only edit this property when the Tilemap’s Orientation is set to Custom. |
Rotation | Rotation of the current orientation matrix. You can only edit this property when the Tilemap’s Orientation is set to Custom. |
Scale | Scale of the current orientation matrix. You can only edit this property when the Tilemap’s Orientation is set to Custom. |
Tilemap Workflow
Below is the general workflow to create and paint a Tilemap:
Unity also supports specialized types of Tilemaps such as Hexagonal and Isometric Tilemaps. Refer to the documentation on their respective pages for their specific workflows.
2D extras in GitHub
You can download examples of scripted Tiles and Brushes from the 2D Extra GitHub repository. Example projects with these scripted GameObjects are availalbe in the 2D Techdemos Github repository. For descriptions of the different scripts and usage information, refer to the README.md for each repository.
Creating Tiles
Importing and preparing Sprites for Tile Assets
Import the individual Tiles or Tileset images for your Tilemap A GameObject that allows you to quickly create 2D levels using tiles and a grid overlay. More info
See in Glossary into your Unity Project by placing the Textures into the Assets folder. Select the imported images to view their Texture Importer settings in the Inspector A Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary window.
Sprite Importer settings.
When importing Sprites for use in a Tilemap, use the following recommended settings. For further information about each setting, refer to the documentation on Texture Type: Sprite (2D and UI).
Generating Tile Assets automatically in the Tile Palette
Tiles can be automatically generated by bringing the individual Sprites or Sprite sheets of the Tiles directly into the Tile Palette window (if the window is not open, go to Window > 2D > Tile Palette).
First prepare and import the Tile Sprites, then open the ‘New Palette’ drop-down menu in the Tile Palette window. Select an existing Tile Palette from the list, or select ‘Create New Palette’ to open the Create New Palette dialog box.
The New Palette drop-down menu.
After selecting the properties of the Tile Palette (refer to the Tile Palettes documentation for more information about the different options), select Create to open the new Palette in the window.
Select ‘Create’ to create a new Tile Palette.
After creating or loading a Palette, drag and drop Textures or Sprites from the Assets folder directly onto the Tile Palette window. You will be prompted for the save location for the new Tile Assets. Select the save location, and the new Tile Assets are generated in the selected folder. The generated Tiles are also automatically placed onto the Palette.
Tile Asset credit to Kenney
Deleting Tile Assets
When you delete Tile Assets, they are replaced by placeholder Tiles made of a white square tinted with various shades of pink. The placeholder Tiles are placed on the Tilemaps in the original positions of the deleted Tile Assets.This helps to identify Tile Assets which have been deleted in a project, whether intentionally or accidentally.
Each deleted Tile Asset has a corresponding placeholder Tile with a unique shade of pink that differentiates the placeholders from each other. You can replace these placeholder Tiles with another Tile by using the Flood Fill tool or remove them.