Classe motore
StyleRule
*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.
Sommario
Metodi
GetDefaultPropertyTransition():Variant |
GetProperty(name: string):Variant |
SetDefaultPropertyTransition(transitionParams: Variant):() |
SetProperties(styleProperties: Dictionary):() |
SetProperty(name: string,value: Variant):() |
SetPropertyTransition(property: string,transitionParams: Variant):() |
SetPropertyTransitions(properties: Dictionary):() |
Riferimento API
Proprietà
Selector
Campioni di codice
Selettore di Classe 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
-- Selettore di classe
rule.Selector = "TextButton"
-- Imposta le proprietà della regola
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 Principale"
button.Parent = screenGuiSelettore di 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
-- Selettore di tag
rule.Selector = ".ButtonPrimary"
-- Imposta le proprietà della regola
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 Principale"
button.Parent = screenGui
-- Applica tag al pulsante
CollectionService:AddTag(button, "ButtonPrimary")Selettore di Modificatori 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
-- Selettore di componenti UI
rule.Selector = "Frame.RoundedCorner20::UICorner"
-- Imposta la proprietà della regola
rule:SetProperty("CornerRadius", UDim.new(0, 20))
-- Crea un frame
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.4, 0, 0.2, 0)
frame.Parent = screenGui
-- Applica il tag al frame
CollectionService:AddTag(frame, "RoundedCorner20")Selettore di Query dello Stile 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
-- Dichiara i selettori di query di stile
smallRule.Selector = "@Small"
mediumRule.Selector = "@Medium"
-- Imposta le proprietà della regola
smallRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("FF0099"),
["Text"] = "Contenitore Piccolo",
["TextColor3"] = Color3.fromHex("E1E1E1"),
["TextSize"] = 12,
})
mediumRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("F0F0F0"),
["Text"] = "Contenitore Medio",
["TextColor3"] = Color3.fromHex("0022FC"),
["TextSize"] = 24,
})
local button = Instance.new("TextButton")
button.Text = "Menu Principale"
button.Parent = screenGui
button.Size = UDim2.fromScale(0.5, 0.2)
-- Crea query di stile con nomi che corrispondono ai selettori di regole di stile
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),
})Metodi
GetDefaultPropertyTransition
StyleRule:GetDefaultPropertyTransition():Variant
Restituzioni
Variant
GetPropertyTransitions
Restituzioni
Campioni di codice
GetPropertyTransitions()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Ottieni riferimento alla regola di stile
local frameRule = coreSheet.Frame
-- Imposta alcune transizioni
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(1, Enum.EasingStyle.Linear))
frameRule:SetPropertyTransition("BackgroundTransparency", "$DefaultTransition")
local transitions = frameRule:GetPropertyTransitions()
print(transitions)SetDefaultPropertyTransition
StyleRule:SetDefaultPropertyTransition(transitionParams:Variant):()
Parametri
transitionParams:Variant |
Restituzioni
()
SetProperties
Parametri
Restituzioni
()
SetProperty
SetPropertyTransition
Parametri
transitionParams:Variant |
Restituzioni
()
Campioni di codice
SetPropertyTransition()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Ottieni riferimento alla regola di stile
local frameRule = coreSheet.Frame
-- Imposta una transizione lineare di 1 secondo su BackgroundColor3
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(
1, -- Tempo
Enum.EasingStyle.Linear -- Stile di Easing
))
-- Rimuovi la transizione
frameRule:SetPropertyTransition("BackgroundColor3", nil)SetPropertyTransition() Utilizzando i Token
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokensSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Imposta i token (attributi) sul foglio dei token
tokensSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
-- Ottieni riferimento alla regola di stile
local frameRule = coreSheet.Frame
frameRule:SetPropertyTransition("BackgroundColor3", "$LinearTransition")SetPropertyTransitions
Parametri
Restituzioni
()
Campioni di codice
SetPropertyTransitions()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Ottieni riferimento alla regola di stile
local frameRule = coreSheet.Frame
-- Imposta le transizioni per due proprietà contemporaneamente
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = TweenInfo.new(1, Enum.EasingStyle.Linear),
["BackgroundTransparency"] = TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
})
-- Rimuovi tutte le transizioni
frameRule:SetPropertyTransitions({})SetPropertyTransitions() Utilizzando Token
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokenSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Imposta i token (attributi) sul foglio dei token
tokenSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
tokenSheet:SetAttribute("QuadTransition", TweenInfo.new(0.25, Enum.EasingStyle.Quad))
-- Ottieni riferimento alla regola di stile
local frameRule = coreSheet.Frame
-- Imposta le transizioni per più proprietà contemporaneamente
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = "$LinearTransition",
["BackgroundTransparency"] = "$QuadTransition",
})