Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

ResourceImporterTextureAtlas

继承: ResourceImporter < RefCounted < Object

将 PNG 图像中的纹理集合导入到优化的 AtlasTexture 中以进行 2D 渲染。

描述

这会将 PNG 图像中的纹理集合导入到 AtlasTexture 或 2D ArrayMesh 中。从精灵表导入 2D 动画时,这可被用于节省内存。纹理图集仅支持在 2D 中渲染,不支持 3D。另请参见 ResourceImporterTextureResourceImporterLayeredTexture

注意:ResourceImporterTextureAtlas 不处理导入 TileSetAtlasSource,它是使用 TileSet 编辑器创建的。

属性

String

atlas_file

""

bool

crop_to_region

false

int

import_mode

0

bool

trim_alpha_border_from_region

true


属性说明

String atlas_file = ""

图集精灵表的路径。该属性必须被设置为 PNG 图像的有效路径。否则,图集将无法导入。


bool crop_to_region = false

如果为 true,则丢弃图集中的空白区域。这仅影响最终的精灵定位,而不影响存储。另请参见 trim_alpha_border_from_region

注意:仅当 import_mode区块时有效。


int import_mode = 0

区块:将图集导入到 AtlasTexture 资源中,该资源被渲染为矩形。这渲染速度很快,但如果 trim_alpha_border_from_region 无法有效修剪透明区域,则仍然必须渲染透明区域。 在屏幕上渲染大型精灵时,这会降低性能。

网格:将图集导入为 ArrayMesh 资源,保持原始位图可见(但被渲染为多边形)。这可被用于在渲染大型透明精灵时降低填充率,但代价是如果精灵中几乎没有透明区域,则渲染速度会变慢。


bool trim_alpha_border_from_region = true

如果为 true,则使用裁剪矩形(从不旋转)修剪区块以排除完全透明的像素。这可以被用来节省内存。另请参见 crop_to_region

注意:仅当 import_mode区块时有效。