Up to date

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

AtlasTexture

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

裁剪其他 Texture2D 的纹理。

描述

Texture2D 资源,只绘制其 atlas 纹理中的由 region 所定义的那部分。还可以设置一个额外的 margin,这对于小的调整很有用。

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

注意:AtlasTexture 不能在 AnimatedTexture 中使用,并且当在其他 AtlasTexture 资源内时,可能无法在 TextureRect 等节点中正确平铺。

属性

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 ( bool value )

  • bool has_filter_clip ( )

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


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

  • void set_margin ( Rect2 value )

  • Rect2 get_margin ( )

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


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

  • void set_region ( Rect2 value )

  • Rect2 get_region ( )

用于绘制 atlas 的区域。