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.

StyleBoxTexture

Inherits: StyleBox < Resource < RefCounted < Object

基于纹理的九宫格 StyleBox

Description

基于纹理的九宫格 StyleBox,类似于 NinePatchRect。这种样式盒对纹理执行 3×3 缩放,只有中心单元格会被完全拉伸。这样就能够为不同大小的样式盒设计带边框的样式。

Properties

AxisStretchMode

axis_stretch_horizontal

0

AxisStretchMode

axis_stretch_vertical

0

bool

draw_center

true

float

expand_margin_bottom

0.0

float

expand_margin_left

0.0

float

expand_margin_right

0.0

float

expand_margin_top

0.0

Color

modulate_color

Color(1, 1, 1, 1)

Rect2

region_rect

Rect2(0, 0, 0, 0)

Texture2D

texture

float

texture_margin_bottom

0.0

float

texture_margin_left

0.0

float

texture_margin_right

0.0

float

texture_margin_top

0.0

Methods

float

get_expand_margin ( Side margin ) const

float

get_texture_margin ( Side margin ) const

void

set_expand_margin ( Side margin, float size )

void

set_expand_margin_all ( float size )

void

set_texture_margin ( Side margin, float size )

void

set_texture_margin_all ( float size )


Enumerations

enum AxisStretchMode:

AxisStretchMode AXIS_STRETCH_MODE_STRETCH = 0

拉伸样式盒的纹理。这会导致可见的失真,除非纹理大小与样式盒的大小完美匹配。

AxisStretchMode AXIS_STRETCH_MODE_TILE = 1

根据九宫格系统,重复样式盒的纹理,以匹配样式盒的大小。

AxisStretchMode AXIS_STRETCH_MODE_TILE_FIT = 2

根据九宫格系统,重复样式盒的纹理,以匹配样式盒的大小。与 AXIS_STRETCH_MODE_TILE 不同,可能会稍微拉伸纹理以使九宫格纹理平铺无缝。


Property Descriptions

AxisStretchMode axis_stretch_horizontal = 0

控制如何水平拉伸或平铺样式盒的纹理。可能的取值见 AxisStretchMode


AxisStretchMode axis_stretch_vertical = 0

控制如何垂直拉伸或平铺样式盒的纹理。可能的取值见 AxisStretchMode


bool draw_center = true

  • void set_draw_center ( bool value )

  • bool is_draw_center_enabled ( )

如果为 true,将绘制九宫格纹理的中心图块。


float expand_margin_bottom = 0.0

  • void set_expand_margin ( Side margin, float size )

  • float get_expand_margin ( Side margin ) const

绘制时扩展此样式盒的下边距,使其绘制得比请求的大。


float expand_margin_left = 0.0

  • void set_expand_margin ( Side margin, float size )

  • float get_expand_margin ( Side margin ) const

绘制时扩展此样式盒的左边距,使其绘制得比请求的大。


float expand_margin_right = 0.0

  • void set_expand_margin ( Side margin, float size )

  • float get_expand_margin ( Side margin ) const

绘制时扩展此样式盒的右边距,使其绘制得比请求的大。


float expand_margin_top = 0.0