Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

AtlasTexture

继承: Texture2D < Texture < Resource < RefCounted < Object

裁剪其他 Texture2D 的纹理。

描述

Texture2D 资源,只绘制 atlas 纹理中由 region 所定义的那部分区域。还可以设置额外的边距 margin,适用于进行较小的调整。

可以从同一个 atlas 中裁剪出多个 AtlasTexture 资源。将许多较小的纹理打包成一个单一的大纹理有助于优化视频内存成本和渲染调用。

注意:AtlasTexture 不能在 AnimatedTexture 中使用,也无法在 TextureRectSprite2D 等节点中正确平铺。要平铺 AtlasTexture 请修改 region

属性

Texture2D

atlas

bool

filter_clip

false

Rect2

margin

Rect2(0, 0, 0, 0)

Rect2

region

Rect2(0, 0, 0, 0)

bool

resource_local_to_scene

false (overrides Resource)


属性说明

Texture2D atlas 🔗

包含该图集的纹理。可以是任何继承自 Texture2D 的类型,包括其他 AtlasTexture


bool filter_clip = false 🔗

  • void set_filter_clip(value: bool)

  • bool has_filter_clip()

如果为 true,则 region 之外的区域将被裁剪以避免周围纹理像素的渗色。


Rect2 margin = Rect2(0, 0, 0, 0) 🔗

  • void set_margin(value: Rect2)

  • Rect2 get_margin()

围绕 region 的边距。对小的调整很有用。如果设置了该属性(编辑器中的“w”和“h”)的 Rect2.size,则绘制的纹理将被调整大小以适合该边距。


Rect2 region = Rect2(0, 0, 0, 0) 🔗

  • void set_region(value: Rect2)

  • Rect2 get_region()

绘制 atlas 的区域。如果区域在某个方向上大小为 0,则该方向会使用 atlas 的大小。