Pelajari
Kelas Engine
StyleRule

*Konten ini diterjemahkan menggunakan AI (Beta) dan mungkin mengandung kesalahan. Untuk melihat halaman ini dalam bahasa Inggris, klik di sini.


Rangkuman
Metode
GetProperty(name: string):Variant
SetDefaultPropertyTransition(transitionParams: Variant):()
SetProperties(styleProperties: Dictionary):()
SetProperty(name: string,value: Variant):()
SetPropertyTransition(property: string,transitionParams: Variant):()
Anggota yang Diwariskan

Referensi API
Properti
Priority
Baca Paralel
Kemampuan: UI
StyleRule.Priority:number

Selector
Baca Paralel
Kemampuan: UI
StyleRule.Selector:string
Contoh Kode
Pemilih Kelas UI
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local screenGui = script.Parent
local coreSheet = Instance.new("StyleSheet")
coreSheet.Parent = ReplicatedStorage
local styleLink = Instance.new("StyleLink")
styleLink.StyleSheet = coreSheet
styleLink.Parent = screenGui
local rule = Instance.new("StyleRule")
rule.Parent = coreSheet
-- Pemilih kelas
rule.Selector = "TextButton"
-- Atur properti aturan
rule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("335FFF"),
["TextColor3"] = Color3.fromHex("E1E1E1"),
["Size"] = UDim2.new(0.15, 0, 0, 40),
["BorderSizePixel"] = 0,
})
local button = Instance.new("TextButton")
button.Text = "Menu Utama"
button.Parent = screenGui
Pemilih Tag UI
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local screenGui = script.Parent
local coreSheet = Instance.new("StyleSheet")
coreSheet.Parent = ReplicatedStorage
local styleLink = Instance.new("StyleLink")
styleLink.StyleSheet = coreSheet
styleLink.Parent = screenGui
local rule = Instance.new("StyleRule")
rule.Parent = coreSheet
-- Pemilih tag
rule.Selector = ".ButtonPrimary"
-- Atur properti aturan
rule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("FF0099"),
["TextColor3"] = Color3.fromHex("E1E1E1"),
["Size"] = UDim2.new(0.15, 0, 0, 40),
["BorderSizePixel"] = 0,
})
local button = Instance.new("TextButton")
button.Text = "Menu Utama"
button.Parent = screenGui
-- Terapkan tag ke tombol
CollectionService:AddTag(button, "ButtonPrimary")
Pemilih Modifikasi UI
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local screenGui = script.Parent
local coreSheet = Instance.new("StyleSheet")
coreSheet.Parent = ReplicatedStorage
local styleLink = Instance.new("StyleLink")
styleLink.StyleSheet = coreSheet
styleLink.Parent = screenGui
local rule = Instance.new("StyleRule")
rule.Parent = coreSheet
-- Pemilih komponen UI
rule.Selector = "Frame.RoundedCorner20::UICorner"
-- Atur properti aturan
rule:SetProperty("CornerRadius", UDim.new(0, 20))
-- Buat frame
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.4, 0, 0.2, 0)
frame.Parent = screenGui
-- Terapkan tag ke frame
CollectionService:AddTag(frame, "RoundedCorner20")
Pemilih Kuery Gaya UI
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local screenGui = script.Parent
local coreSheet = Instance.new("StyleSheet")
coreSheet.Parent = ReplicatedStorage
local styleLink = Instance.new("StyleLink")
styleLink.StyleSheet = coreSheet
styleLink.Parent = screenGui
local smallRule = Instance.new("StyleRule")
smallRule.Parent = coreSheet
local mediumRule = Instance.new("StyleRule")
mediumRule.Parent = coreSheet
-- Deklarasikan pemilih kuery gaya
smallRule.Selector = "@Small"
mediumRule.Selector = "@Medium"
-- Atur properti aturan
smallRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("FF0099"),
["Text"] = "Wadah Kecil",
["TextColor3"] = Color3.fromHex("E1E1E1"),
["TextSize"] = 12,
})
mediumRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("F0F0F0"),
["Text"] = "Wadah Sedang",
["TextColor3"] = Color3.fromHex("0022FC"),
["TextSize"] = 24,
})
local button = Instance.new("TextButton")
button.Text = "Menu Utama"
button.Parent = screenGui
button.Size = UDim2.fromScale(0.5, 0.2)
-- Buat kuery gaya dengan nama yang cocok dengan pemilih aturan gaya
local mediumSQ = Instance.new("StyleQuery")
mediumSQ.Parent = button
mediumSQ.Name = "Medium"
mediumSQ:SetConditions({
["MinSize"] = Vector2.new(200, 0),
})
local smallSQ = Instance.new("StyleQuery")
smallSQ.Parent = button
smallSQ.Name = "Small"
smallSQ:SetConditions({
["MaxSize"] = Vector2.new(200, math.huge),
["MinSize"] = Vector2.new(0, 0),
})

SelectorError
Hanya Baca
Tidak Direplikasi
Baca Paralel
Kemampuan: UI
StyleRule.SelectorError:string

Metode
GetDefaultPropertyTransition
Kemampuan: UI
StyleRule:GetDefaultPropertyTransition():Variant
Memberikan nilai
Variant

GetProperties
Kemampuan: UI
StyleRule:GetProperties():Dictionary
Memberikan nilai

GetProperty
Kemampuan: UI
StyleRule:GetProperty(name:string):Variant
Parameter
name:string
Memberikan nilai
Variant

GetPropertyTransitions
Kemampuan: UI
StyleRule:GetPropertyTransitions():Dictionary
Memberikan nilai
Contoh Kode
GetPropertyTransitions()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Dapatkan referensi ke aturan gaya
local frameRule = coreSheet.Frame
-- Atur beberapa transisi
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(1, Enum.EasingStyle.Linear))
frameRule:SetPropertyTransition("BackgroundTransparency", "$DefaultTransition")
local transitions = frameRule:GetPropertyTransitions()
print(transitions)

SetDefaultPropertyTransition
Kemampuan: UI
StyleRule:SetDefaultPropertyTransition(transitionParams:Variant):()
Parameter
transitionParams:Variant
Memberikan nilai
()

SetProperties
Kemampuan: UI
StyleRule:SetProperties(styleProperties:Dictionary):()
Parameter
styleProperties:Dictionary
Memberikan nilai
()

SetProperty
Kemampuan: UI
StyleRule:SetProperty(
name:string, value:Variant
):()
Parameter
name:string
value:Variant
Memberikan nilai
()

SetPropertyTransition
Kemampuan: UI
StyleRule:SetPropertyTransition(
property:string, transitionParams:Variant
):()
Parameter
property:string
transitionParams:Variant
Memberikan nilai
()
Contoh Kode
SetPropertyTransition()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Ambil referensi ke aturan gaya
local frameRule = coreSheet.Frame
-- Atur transisi linier 1 detik pada BackgroundColor3
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(
1, -- Waktu
Enum.EasingStyle.Linear -- GayaEasing
))
-- Hapus transisi
frameRule:SetPropertyTransition("BackgroundColor3", nil)
SetPropertyTransition() Menggunakan Token
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokensSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Atur token (atribut) di lembar token
tokensSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
-- Dapatkan referensi ke aturan gaya
local frameRule = coreSheet.Frame
frameRule:SetPropertyTransition("BackgroundColor3", "$LinearTransition")

SetPropertyTransitions
Kemampuan: UI
StyleRule:SetPropertyTransitions(properties:Dictionary):()
Parameter
properties:Dictionary
Memberikan nilai
()
Contoh Kode
SetPropertyTransitions()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Dapatkan referensi ke aturan gaya
local frameRule = coreSheet.Frame
-- Mengatur transisi untuk dua properti sekaligus
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = TweenInfo.new(1, Enum.EasingStyle.Linear),
["BackgroundTransparency"] = TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
})
-- Hapus semua transisi
frameRule:SetPropertyTransitions({})
SetPropertyTransitions() Menggunakan Token
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokenSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Atur token (atribut) pada lembar token
tokenSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
tokenSheet:SetAttribute("QuadTransition", TweenInfo.new(0.25, Enum.EasingStyle.Quad))
-- Ambil referensi ke aturan gaya
local frameRule = coreSheet.Frame
-- Atur transisi untuk beberapa properti sekaligus
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = "$LinearTransition",
["BackgroundTransparency"] = "$QuadTransition",
})

©2026 Roblox Corporation. Roblox, logo Roblox, dan Powering Imagination termasuk dalam merek dagang kami yang terdaftar dan tidak terdaftar di AS dan negara lainnya.