StyleRule

แสดงที่เลิกใช้งานแล้ว

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

กำหนดคุณสมบัติสไตล์ที่เหนือกว่าคุณสมบัติในตัวอย่างที่ได้รับผลกระทบจากคุณสมบัติ Selector โปรปรียา

สรุป

คุณสมบัติ

  • อ่านพร้อมๆ กัน

    จํานวนที่กําหนดวิธีที่คุณสมบัติของ StyleRule สามารถใช้เป็นสัดส่วนกับคุณสมบัติเดียวกันในอื่น ๆ StyleRulesค่าลําดับความสําคัญสูงกว่ามีลําดับความสําคัญก่อนค่าลําดับความสําคัญต่ํากว่า

  • อ่านพร้อมๆ กัน

    สตริงที่ระบุว่าตัวอย่างใดที่ StyleRule ควรส่งผลกระทบต่อ

  • อ่านอย่างเดียว
    ไม่ซ้ำ
    อ่านพร้อมๆ กัน

    สตริงอ่านเฉพาะที่แสดงข้อผิดพลาดจากคุณสมบัติ Selector

วิธีการ

  • คืนสารานุกรมของคู่คีย์-ค่าที่อธิบายคุณสมบัติของ StyleRule

  • GetProperty(name : string):Variant

    คืนค่าของคุณสมบัติเฉพาะใน StyleRule

  • SetProperties(styleProperties : Dictionary):()

    ให้คุณประกาศและตั้งค่าคุณสมบัติหลายอย่างของ StyleRule ในครั้งเดียว

  • SetProperty(name : string,value : Variant):()
วิธีการรับทอดมาจากStyleBase

วิธีการ

เหตุการณ์

เหตุการณ์รับทอดมาจากStyleBase

เหตุการณ์

คุณสมบัติ

Priority

อ่านพร้อมๆ กัน

Selector

อ่านพร้อมๆ กัน

ตัวอย่างโค้ด

UI Class Selector

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
-- Class selector
rule.Selector = "TextButton"
-- Set rule properties
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 = "Main Menu"
button.Parent = screenGui
UI Tag Selector

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
-- Tag selector
rule.Selector = ".ButtonPrimary"
-- Set rule properties
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 = "Main Menu"
button.Parent = screenGui
-- Apply tag to button
CollectionService:AddTag(button, "ButtonPrimary")
UI Modifier Selector

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 component selector
rule.Selector = "Frame.RoundedCorner20::UICorner"
-- Set rule property
rule:SetProperty("CornerRadius", UDim.new(0, 20))
-- Create frame
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.4, 0, 0.2, 0)
frame.Parent = screenGui
-- Apply tag to frame
CollectionService:AddTag(frame, "RoundedCorner20")

SelectorError

อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน

วิธีการ

GetProperties


ส่งค่ากลับ

GetProperty

Variant

พารามิเตอร์

name: string
ค่าเริ่มต้น: ""

ส่งค่ากลับ

Variant

SetProperties

()

พารามิเตอร์

styleProperties: Dictionary
ค่าเริ่มต้น: ""

ส่งค่ากลับ

()

SetProperty

()

พารามิเตอร์

name: string
ค่าเริ่มต้น: ""
value: Variant
ค่าเริ่มต้น: ""

ส่งค่ากลับ

()

เหตุการณ์