当前位置: 首页> 财经> 股票 > Unity补完计划之 TileMap组件

Unity补完计划之 TileMap组件

时间:2025/7/11 8:00:27来源:https://blog.csdn.net/2301_77947509/article/details/140987862 浏览次数:0次

本文仅作笔记学习和分享,不用做任何商业用途

本文包括但不限于unity官方手册,unity唐老狮等教程知识,如有不足还请斧正

当你创建一个 tilemap对象之后,可以看到如下内容

 

1.Grid

Grid - Unity 手册

Grid 组件是有助于根据选定的布局来对齐游戏对象(如瓦片)的导引网格。该组件将网格单元格位置转换为游戏对象的相应__局部坐标,然后,Transform 组件将这些局部坐标转换为世界空间或__全局坐标

2.Tilemap

Tilemap component reference - Unity 手册

Tilemap 组件存储和管理用于创建 2D 关卡的 Tile 资产,它将放置在其上的瓦片所需的信息传输到其他相关组件,例如 Tilemap Renderer 和 Tilemap Collider 2D

当您使用 2D 模板创建项目时,将自动安装 2D Tilemap Editor 包,您可以通过包管理器直接从 Unity 注册表安装 2D Tilemap 编辑器

可以拓展的知识:

Unity - Scripting API: UnityEngine.TilemapModule

Tilemap 模块实现了 Tilemap 类

3.tilemap renderer

Tilemap Renderer 模式 - Unity 手册

其中比较重要的就是渲染模式,分为chunk与individual

chunk Mode

When set to Chunk Mode, the Tilemap Renderer handles Sprites on a Tilemap in batches and renders them together. They’re treated as a single sort item when sorted in the 2D Transparent Queue. While this reduces draw calls, other renderers can’t render between any part of the Tilemap, preventing other rendered Sprites from interweaving with Tilemap Sprites.

为什么会发生不同渲染器下sprite不能交互的情况?

因为渲染顺序的原因,大批量渲染内容导致覆盖或者被覆盖,请参考2D 排序 - Unity 手册

所以为了解决交互问题,出现了Individual mode

Individual Mode

In this mode, the Tilemap Renderer sorts sprites based on their position on the Tilemap and the sorting properties set in the Tilemap Renderer. For example, this allows a character sprite to go in-between obstacle sprites (refer to the example below)

在 Individual Mode 模式下,Tilemap Renderer 会对瓦片地图上的精灵进行排序和渲染,同时考虑场景中的其他渲染器,例如 Sprite Renderer 和 Mesh Renderer。如果其他渲染器与瓦片地图上的精灵和对象进行交互,请使用此模式

关键字:Unity补完计划之 TileMap组件

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: