เรียนรู้
Engine Class
StyleRule

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
วิธีการ
GetProperty(name: string):Variant
SetDefaultPropertyTransition(transitionParams: Variant):()
SetProperties(styleProperties: Dictionary):()
SetProperty(name: string,value: Variant):()
SetPropertyTransition(property: string,transitionParams: Variant):()
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
Priority
อ่านพร้อมๆ กัน
ความสามารถ: UI
StyleRule.Priority:number

Selector
อ่านพร้อมๆ กัน
ความสามารถ: UI
StyleRule.Selector:string
ตัวอย่างโค้ด
ตัวเลือกคลาส 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
-- ตัวเลือกคลาส
rule.Selector = "TextButton"
-- กำหนดคุณสมบัติของกฎ
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 = "เมนูหลัก"
button.Parent = screenGui
ตัวเลือกแท็ก 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
-- ตัวเลือกแท็ก
rule.Selector = ".ButtonPrimary"
-- กำหนดคุณสมบัติของกฎ
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 = "เมนูหลัก"
button.Parent = screenGui
-- เพิ่มแท็กให้กับปุ่ม
CollectionService:AddTag(button, "ButtonPrimary")
ตัวเลือกโมดิฟายเออร์ 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
-- ตัวเลือกคอมโพเนนต์ UI
rule.Selector = "Frame.RoundedCorner20::UICorner"
-- ตั้งค่า property ของ rule
rule:SetProperty("CornerRadius", UDim.new(0, 20))
-- สร้างกรอบ
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.4, 0, 0.2, 0)
frame.Parent = screenGui
-- ใช้แท็กกับกรอบ
CollectionService:AddTag(frame, "RoundedCorner20")
ตัวเลือกการค้นหาสไตล์ 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
-- ประกาศตัวเลือกการค้นหาสไตล์
smallRule.Selector = "@Small"
mediumRule.Selector = "@Medium"
-- ตั้งค่าคุณสมบัติของกฎ
smallRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("FF0099"),
["Text"] = "กล่องขนาดเล็ก",
["TextColor3"] = Color3.fromHex("E1E1E1"),
["TextSize"] = 12,
})
mediumRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("F0F0F0"),
["Text"] = "กล่องขนาดกลาง",
["TextColor3"] = Color3.fromHex("0022FC"),
["TextSize"] = 24,
})
local button = Instance.new("TextButton")
button.Text = "เมนูหลัก"
button.Parent = screenGui
button.Size = UDim2.fromScale(0.5, 0.2)
-- สร้างการค้นหาสไตล์ที่มีชื่อสอดคล้องกับตัวเลือกการค้นหาสไตล์
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
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: UI
StyleRule.SelectorError:string

วิธีการ
GetDefaultPropertyTransition
ความสามารถ: UI
StyleRule:GetDefaultPropertyTransition():Variant
ส่งค่ากลับ
Variant

GetProperties
ความสามารถ: UI
StyleRule:GetProperties():Dictionary
ส่งค่ากลับ

GetProperty
ความสามารถ: UI
StyleRule:GetProperty(name:string):Variant
พารามิเตอร์
name:string
ส่งค่ากลับ
Variant

GetPropertyTransitions
ความสามารถ: UI
StyleRule:GetPropertyTransitions():Dictionary
ส่งค่ากลับ
ตัวอย่างโค้ด
GetPropertyTransitions()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- รับการอ้างอิงไปยังกฎสไตล์
local frameRule = coreSheet.Frame
-- ตั้งค่าการเปลี่ยนแปลงบางอย่าง
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(1, Enum.EasingStyle.Linear))
frameRule:SetPropertyTransition("BackgroundTransparency", "$DefaultTransition")
local transitions = frameRule:GetPropertyTransitions()
print(transitions)

SetDefaultPropertyTransition
ความสามารถ: UI
StyleRule:SetDefaultPropertyTransition(transitionParams:Variant):()
พารามิเตอร์
transitionParams:Variant
ส่งค่ากลับ
()

SetProperties
ความสามารถ: UI
StyleRule:SetProperties(styleProperties:Dictionary):()
พารามิเตอร์
styleProperties:Dictionary
ส่งค่ากลับ
()

SetProperty
ความสามารถ: UI
StyleRule:SetProperty(
name:string, value:Variant
):()
พารามิเตอร์
name:string
value:Variant
ส่งค่ากลับ
()

SetPropertyTransition
ความสามารถ: UI
StyleRule:SetPropertyTransition(
property:string, transitionParams:Variant
):()
พารามิเตอร์
property:string
transitionParams:Variant
ส่งค่ากลับ
()
ตัวอย่างโค้ด
SetPropertyTransition()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- ดึงข้อมูลการอ้างอิงจากกฎสไตล์
local frameRule = coreSheet.Frame
-- ตั้งค่าการเปลี่ยนแปลงแบบเชิงเส้น 1 วินาทีสำหรับ BackgroundColor3
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(
1, -- เวลา
Enum.EasingStyle.Linear -- รูปแบบการทำให้เรียบ
))
-- ลบการเปลี่ยนแปลง
frameRule:SetPropertyTransition("BackgroundColor3", nil)
SetPropertyTransition() การใช้โทเคน
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokensSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- กำหนดโทเคน (คุณสมบัติ) บนแผ่นโทเคน
tokensSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
-- รับอ้างอิงไปยังกฎสไตล์
local frameRule = coreSheet.Frame
frameRule:SetPropertyTransition("BackgroundColor3", "$LinearTransition")

SetPropertyTransitions
ความสามารถ: UI
StyleRule:SetPropertyTransitions(properties:Dictionary):()
พารามิเตอร์
properties:Dictionary
ส่งค่ากลับ
()
ตัวอย่างโค้ด
ตั้งค่าสถานะการเปลี่ยนแปลงคุณสมบัติ()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- รับอ้างอิงถึงกฎสไตล์
local frameRule = coreSheet.Frame
-- ตั้งค่าสถานะการเปลี่ยนแปลงสำหรับสองคุณสมบัติพร้อมกัน
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = TweenInfo.new(1, Enum.EasingStyle.Linear),
["BackgroundTransparency"] = TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
})
-- ลบการเปลี่ยนแปลงทั้งหมด
frameRule:SetPropertyTransitions({})
SetPropertyTransitions() โดยใช้โทเค็น
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokenSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- ตั้งค่าโทเค็น (แอตทริบิวต์) บนแผ่นโทเค็น
tokenSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
tokenSheet:SetAttribute("QuadTransition", TweenInfo.new(0.25, Enum.EasingStyle.Quad))
-- รับการอ้างอิงถึงกฎสไตล์
local frameRule = coreSheet.Frame
-- ตั้งค่าการเปลี่ยนแปลงสำหรับหลาย ๆ คุณสมบัติในครั้งเดียว
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = "$LinearTransition",
["BackgroundTransparency"] = "$QuadTransition",
})

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ