TextureRect

继承: Control < CanvasItem < Node < Object

A control that displays a texture.

描述

A control that displays a texture, for example an icon inside a GUI. The texture's placement can be controlled with the stretch_mode property. It can scale, tile, or stay centered inside its bounding rectangle.

属性


枚举

enum ExpandMode:

ExpandMode EXPAND_KEEP_SIZE = 0

The minimum size will be equal to texture size, i.e. TextureRect can't be smaller than the texture.

ExpandMode EXPAND_IGNORE_SIZE = 1

The size of the texture won't be considered for minimum size calculation, so the TextureRect can be shrunk down past the texture size.

ExpandMode EXPAND_FIT_WIDTH = 2

The height of the texture will be ignored. Minimum width will be equal to the current height. Useful for horizontal layouts, e.g. inside HBoxContainer.

ExpandMode EXPAND_FIT_WIDTH_PROPORTIONAL = 3

Same as EXPAND_FIT_WIDTH, but keeps texture's aspect ratio.

ExpandMode EXPAND_FIT_HEIGHT = 4

The width of the texture will be ignored. Minimum height will be equal to the current width. Useful for vertical layouts, e.g. inside VBoxContainer.

ExpandMode EXPAND_FIT_HEIGHT_PROPORTIONAL = 5

Same as EXPAND_FIT_HEIGHT, but keeps texture's aspect ratio.


enum StretchMode:

StretchMode STRETCH_SCALE = 0

Scale to fit the node's bounding rectangle.

StretchMode STRETCH_TILE = 1

Tile inside the node's bounding rectangle.

StretchMode STRETCH_KEEP = 2

The texture keeps its original size and stays in the bounding rectangle's top-left corner.

StretchMode STRETCH_KEEP_CENTERED = 3

The texture keeps its original size and stays centered in the node's bounding rectangle.

StretchMode STRETCH_KEEP_ASPECT = 4

Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.

StretchMode STRETCH_KEEP_ASPECT_CENTERED = 5

Scale the texture to fit the node's bounding rectangle, center it and maintain its aspect ratio.

StretchMode STRETCH_KEEP_ASPECT_COVERED = 6

Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.


属性说明

ExpandMode expand_mode = 0

实验性: Using EXPAND_FIT_WIDTH, EXPAND_FIT_WIDTH_PROPORTIONAL, EXPAND_FIT_HEIGHT, or EXPAND_FIT_HEIGHT_PROPORTIONAL may result in unstable behavior in some Container controls. This behavior may be re-evaluated and changed in the future.

Defines how minimum size is determined based on the texture's size. See ExpandMode for options.


bool flip_h = false

  • void set_flip_h ( value: bool )
  • bool is_flipped_h ( )

If true, texture is flipped horizontally.


bool flip_v = false

  • void set_flip_v ( value: bool )
  • bool is_flipped_v ( )

If true, texture is flipped vertically.


StretchMode stretch_mode = 0

Controls the texture's behavior when resizing the node's bounding rectangle. See StretchMode.


Texture2D texture

The node's Texture2D resource.

1

本方法通常需要用户覆盖才能生效。

2

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。