Aprender
Clase de motor
StyleRule

*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.


Resumen
Métodos
GetProperty(name: string):Variant
SetDefaultPropertyTransition(transitionParams: Variant):()
SetProperties(styleProperties: Dictionary):()
SetProperty(name: string,value: Variant):()
SetPropertyTransition(property: string,transitionParams: Variant):()
Miembros heredados

Referencia API
Propiedades
Priority
Leer paralelo
Capacidades: UI
StyleRule.Priority:number

Selector
Leer paralelo
Capacidades: UI
StyleRule.Selector:string
Muestras de código
Selector de Clase de 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
-- Selector de clase
rule.Selector = "TextButton"
-- Establecer propiedades de la regla
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 = "Menú Principal"
button.Parent = screenGui
Selector de Etiquetas de 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
-- Selector de etiquetas
rule.Selector = ".ButtonPrimary"
-- Establecer propiedades de la regla
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 = "Menú Principal"
button.Parent = screenGui
-- Aplicar etiqueta al botón
CollectionService:AddTag(button, "ButtonPrimary")
Selector de modificador de 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
-- Selector de componente de UI
rule.Selector = "Frame.RoundedCorner20::UICorner"
-- Establecer propiedad de la regla
rule:SetProperty("CornerRadius", UDim.new(0, 20))
-- Crear marco
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.4, 0, 0.2, 0)
frame.Parent = screenGui
-- Aplicar etiqueta al marco
CollectionService:AddTag(frame, "RoundedCorner20")
Selector de consulta de estilo de 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
-- Declarar selectores de consulta de estilo
smallRule.Selector = "@Small"
mediumRule.Selector = "@Medium"
-- Establecer propiedades de la regla
smallRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("FF0099"),
["Text"] = "Contenedor Pequeño",
["TextColor3"] = Color3.fromHex("E1E1E1"),
["TextSize"] = 12,
})
mediumRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("F0F0F0"),
["Text"] = "Contenedor Mediano",
["TextColor3"] = Color3.fromHex("0022FC"),
["TextSize"] = 24,
})
local button = Instance.new("TextButton")
button.Text = "Menú Principal"
button.Parent = screenGui
button.Size = UDim2.fromScale(0.5, 0.2)
-- Crear consultas de estilo con nombres que coinciden con los selectores de reglas de estilo
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
Solo lectura
No replicado
Leer paralelo
Capacidades: UI
StyleRule.SelectorError:string

Métodos
GetDefaultPropertyTransition
Capacidades: UI
StyleRule:GetDefaultPropertyTransition():Variant
Devuelve
Variant

GetProperties
Capacidades: UI
StyleRule:GetProperties():Dictionary
Devuelve

GetProperty
Capacidades: UI
StyleRule:GetProperty(name:string):Variant
Parámetros
name:string
Devuelve
Variant

GetPropertyTransitions
Capacidades: UI
StyleRule:GetPropertyTransitions():Dictionary
Devuelve
Muestras de código
GetPropertyTransitions()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Obtener referencia a la regla de estilo
local frameRule = coreSheet.Frame
-- Establecer algunas transiciones
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(1, Enum.EasingStyle.Linear))
frameRule:SetPropertyTransition("BackgroundTransparency", "$DefaultTransition")
local transitions = frameRule:GetPropertyTransitions()
print(transitions)

SetDefaultPropertyTransition
Capacidades: UI
StyleRule:SetDefaultPropertyTransition(transitionParams:Variant):()
Parámetros
transitionParams:Variant
Devuelve
()

SetProperties
Capacidades: UI
StyleRule:SetProperties(styleProperties:Dictionary):()
Parámetros
styleProperties:Dictionary
Devuelve
()

SetProperty
Capacidades: UI
StyleRule:SetProperty(
name:string, value:Variant
):()
Parámetros
name:string
value:Variant
Devuelve
()

SetPropertyTransition
Capacidades: UI
StyleRule:SetPropertyTransition(
property:string, transitionParams:Variant
):()
Parámetros
property:string
transitionParams:Variant
Devuelve
()
Muestras de código
SetPropertyTransition()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Obtener referencia a la regla de estilo
local frameRule = coreSheet.Frame
-- Establecer una transición lineal de 1 segundo en BackgroundColor3
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(
1, -- Tiempo
Enum.EasingStyle.Linear -- Estilo de easing
))
-- Eliminar la transición
frameRule:SetPropertyTransition("BackgroundColor3", nil)
SetPropertyTransition() Usando Tokens
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokensSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Establecer tokens (atributos) en la hoja de tokens
tokensSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
-- Obtener referencia a la regla de estilo
local frameRule = coreSheet.Frame
frameRule:SetPropertyTransition("BackgroundColor3", "$LinearTransition")

SetPropertyTransitions
Capacidades: UI
StyleRule:SetPropertyTransitions(properties:Dictionary):()
Parámetros
properties:Dictionary
Devuelve
()
Muestras de código
SetPropertyTransitions()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Obtén la referencia a la regla de estilo
local frameRule = coreSheet.Frame
-- Establece transiciones para dos propiedades a la vez
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = TweenInfo.new(1, Enum.EasingStyle.Linear),
["BackgroundTransparency"] = TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
})
-- Elimina todas las transiciones
frameRule:SetPropertyTransitions({})
SetPropertyTransitions() Usando Tokens
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokenSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Establecer tokens (atributos) en la hoja de tokens
tokenSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
tokenSheet:SetAttribute("QuadTransition", TweenInfo.new(0.25, Enum.EasingStyle.Quad))
-- Obtener referencia a la regla de estilo
local frameRule = coreSheet.Frame
-- Establecer transiciones para múltiples propiedades a la vez
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = "$LinearTransition",
["BackgroundTransparency"] = "$QuadTransition",
})

©2026 Roblox Corporation. Roblox, el logotipo de Roblox y "Powering Imagination" son algunas de nuestras marcas registradas y no registradas en los Estados Unidos y otros países.