UDim2データ型

データ型日本語解説あり

ひとことで言うと

GUIの位置や大きさを表すデータ型です。画面に対する割合(Scale)と、ピクセル数(Offset)の組み合わせで指定します。

公式の説明(英語):Represents a two-dimensional value where each dimension is composed of a relative scale and an absolute offset.

コンストラクター(作り方)(5)

名前と書き方説明
new
UDim2.new()
横のScale・横のOffset・縦のScale・縦のOffsetを指定して作ります。Returns a new UDim2 with the coordinates of two zero UDim components representing each axis.
new
UDim2.new(xScale: number, xOffset: number, yScale: number, yOffset: number)
横のScale・横のOffset・縦のScale・縦のOffsetを指定して作ります。Returns a new UDim2 given the coordinates of the two UDim components representing each axis.
new
UDim2.new(x: UDim, y: UDim)
横のScale・横のOffset・縦のScale・縦のOffsetを指定して作ります。Returns a new UDim2 from the given UDim objects representing the **X** and **Y** dimensions, respectively.
fromScale
UDim2.fromScale(xScale: number, yScale: number)
割合だけで作ります。Returns a new UDim2 with the given scale components and no offsets.
fromOffset
UDim2.fromOffset(xOffset: number, yOffset: number)
ピクセル数だけで作ります。Returns a new UDim2 with the given offset components and no scaling.

プロパティ(4)

名前と書き方説明
X
UDim2.X: UDim
The **X** dimension scale and offset of the UDim2.
Y
UDim2.Y: UDim
The **Y** dimension scale and offset of the UDim2.
Width
UDim2.Width: UDim
The **X** dimension scale and offset of the UDim2.
Height
UDim2.Height: UDim
The **Y** dimension scale and offset of the UDim2.

メソッド(1)

名前と書き方説明
Lerp
UDim2:Lerp(goal: UDim2, alpha: number): UDim2
Returns a UDim2 interpolated linearly between the value and the given goal.

英語の説明とメンバーの一覧は、Roblox Creator Documentation(UDim2)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。

執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。沖縄マイクラ部 クロスウェーブで、ロブロックス(Roblox)・マインクラフト(マイクラ)・Scratchなどのプログラミングを指導。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにロブロックス(Roblox)やマインクラフト(マイクラ)のプログラミングを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む