TextButton

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

A TextButton はレンダリングに関して、TextLabel と同様の動作をし、追加の動作である GuiButton を持ちます。

テキストレンダリングを無効にするには、TextTransparency1 に設定してください。これにより、ボタンとして使用できるプレーンな長方形が生成されます。

概要

プロパティ

GuiButton から継承した プロパティ

プロパティ

  • 並列読み取り

    ボタンがマウスがホバーしたりクリックしたりすると自動的に色が変更されるかどうかを決定します。

  • A HapticEffect インスタンスは、GuiButton がホバリングされているときに再生する。

  • 並列読み取り

    GUI 要素が表示されている間、true であれば、右マウスボタンが下になっていない限り、マウスはロックされません。

  • A HapticEffect インスタンスは、GuiButton が押されたときに再生する。

  • 並列読み取り

    オブジェクトが選択されたかどうかを示すブールプロパティ。

  • 並列読み取り

    GuiButton のスタイルを、事前決定されたスタイルのリストに基づいて設定します。

GuiObject から継承した プロパティ

プロパティ

GuiBase2d から継承した プロパティ

プロパティ

方法

GuiObject から継承した 方法

方法

イベント

GuiButton から継承した イベント

イベント

GuiObject から継承した イベント

イベント

GuiBase2d から継承した イベント

イベント

プロパティ

ContentText

読み取り専用
複製されていません
並列読み取り
非表示
複製されていません
並列読み取り

コードサンプル

すべてのフォントを表示

local frame = script.Parent
-- 各フォントを表示するテキストラベルを作成
for _, font in pairs(Enum.Font:GetEnumItems()) do
local textLabel = Instance.new("TextLabel")
textLabel.Name = font.Name
-- テキストプロパティを設定する
textLabel.Text = font.Name
textLabel.Font = font
-- 一部のレンダリングプロパティ
textLabel.TextSize = 24
textLabel.TextXAlignment = Enum.TextXAlignment.Left
-- フレームのサイズをテキストの高さと同じにする
textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextSize)
-- 親フレームに追加する
textLabel.Parent = frame
end
-- フレームをリストに配置する(もし、まだでない場合)
if not frame:FindFirstChildOfClass("UIListLayout") then
local uiListLayout = Instance.new("UIListLayout")
uiListLayout.Parent = frame
end

FontFace

並列読み取り

LineHeight

並列読み取り

LocalizedText

非表示
読み取り専用
複製されていません
並列読み取り

MaxVisibleGraphemes

並列読み取り

OpenTypeFeatures

並列読み取り

OpenTypeFeaturesError

読み取り専用
複製されていません
並列読み取り

RichText

並列読み取り

Text

並列読み取り

コードサンプル

Fading Banner

local TweenService = game:GetService("TweenService")
local textLabel = script.Parent
local content = {
"Welcome to my game!",
"Be sure to have fun!",
"Please give suggestions!",
"Be nice to other players!",
"Don't grief other players!",
"Check out the shop!",
"Tip: Don't die!",
}
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local RNG = Random.new()
local fadeIn = TweenService:Create(textLabel, tweenInfo, {
TextTransparency = 0,
})
local fadeOut = TweenService:Create(textLabel, tweenInfo, {
TextTransparency = 1,
})
local lastIndex
while true do
-- Step 0: Fade out before doing anything
fadeOut:Play()
task.wait(tweenInfo.Time)
-- Step 1: pick content that wasn't the last displayed
local index
repeat
index = RNG:NextInteger(1, #content)
until lastIndex ~= index
-- Make sure we don't show the same thing next time
lastIndex = index
-- Step 2: show the content
textLabel.Text = content[index]
fadeIn:Play()
task.wait(tweenInfo.Time + 1)
end
Emoji in Text

local textLabel = script.Parent
local moods = {
["happy"] = "😃",
["sad"] = "😢",
["neutral"] = "😐",
["tired"] = "😫",
}
while true do
for mood, face in pairs(moods) do
textLabel.Text = "I am feeling " .. mood .. "! " .. face
task.wait(1)
end
end

TextBounds

読み取り専用
複製されていません
並列読み取り

TextColor3

並列読み取り

コードサンプル

Countdown Text

-- Place this code in a LocalScript within a TextLabel/TextButton
local textLabel = script.Parent
-- Some colors we'll use with TextColor3
local colorNormal = Color3.new(0, 0, 0) -- black
local colorSoon = Color3.new(1, 0.5, 0.5) -- red
local colorDone = Color3.new(0.5, 1, 0.5) -- green
-- Loop infinitely
while true do
-- Count backwards from 10 to 1
for i = 10, 1, -1 do
-- Set the text
textLabel.Text = "Time: " .. i
-- Set the color based on how much time is left
if i > 3 then
textLabel.TextColor3 = colorNormal
else
textLabel.TextColor3 = colorSoon
end
task.wait(1)
end
textLabel.Text = "GO!"
textLabel.TextColor3 = colorDone
task.wait(2)
end

TextDirection

並列読み取り

TextFits

読み取り専用
複製されていません
並列読み取り

TextScaled

並列読み取り

TextSize

並列読み取り

TextStrokeColor3

並列読み取り

TextStrokeTransparency

並列読み取り

TextTransparency

並列読み取り

TextTruncate

並列読み取り

TextWrapped

並列読み取り

TextXAlignment

並列読み取り

TextYAlignment

並列読み取り

方法

イベント