StyleSheet

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

アグレゲート StyleRules は、インスタンスにスタイルプロパティを適用するために DataModel ツリーにリンクできます。注:StyleSheet は、DataModel の外に存在する可能性がありますが、そのような場合には、DataModel の木に派生したりリンクされたりすることはできません。

概要

方法

  • GetDerives():Instances

    返すのは、StyleSheets から抽出された StyleSheet およびトークン定義のアレイで、その中に StyleRules が派生しています。

  • SetDerives(derives : Instances):()

    StyleSheet を設定して、StyleRules およびトークン定義を 1つまたは複数の他の StyleSheets から派生させます。

StyleBase から継承した 方法

イベント

StyleBase から継承した イベント

プロパティ

方法

GetDerives

Instances

返すのは、StyleSheets から抽出された StyleSheet およびトークン定義のアレイで、その中に StyleRules が派生しています。


戻り値

Instances

他の StyleSheets のアレイ。

SetDerives

()

StyleSheet を設定して、リストされた順序で 1つまたは複数の他の StyleSheets から StyleRules およびトークン定義を派生させます。このメソッドは、適切な StyleDerive インスタンスをスポーンし、指定された派生を設定するための優先順位を設定します。


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- トークンスタイルシートを作成する
local tokensSheet = Instance.new("StyleSheet")
tokensSheet.Name = "Tokens"
tokensSheet.Parent = ReplicatedStorage
-- トークン(属性)をトークンシートに設定する
tokensSheet:SetAttribute("LightGray", Color3.new(0.9, 0.9, 0.9))
tokensSheet:SetAttribute("DarkGray", Color3.new(0.2, 0.2, 0.2))
-- テーマスタイルシートを作成する
local lightThemeSheet = Instance.new("StyleSheet")
lightThemeSheet.Name = "LightTheme"
lightThemeSheet:SetAttribute("Background", "$LightGray")
lightThemeSheet.Parent = ReplicatedStorage
local darkThemeSheet = Instance.new("StyleSheet")
darkThemeSheet.Name = "DarkTheme"
darkThemeSheet:SetAttribute("Background", "$DarkGray")
darkThemeSheet.Parent = ReplicatedStorage
-- テーマシートをトークンシートから派生させるように設定する
lightThemeSheet:SetDerives({ tokensSheet })
darkThemeSheet:SetDerives({ tokensSheet })
local themeDerive = Instance.new("StyleDerive")
themeDerive.Parent = coreSheet
themeDerive.StyleSheet = lightThemeSheet
-- コアシートの派生テーマを動的に変更する機能
local function changeTheme()
if themeDerive.StyleSheet == lightThemeSheet then
themeDerive.StyleSheet = darkThemeSheet
elseif themeDerive.StyleSheet == darkThemeSheet then
themeDerive.StyleSheet = lightThemeSheet
end
end

スタイルエディタを使用してデザインを作成した場合、デザインフォルダの デザイン 下の スタイルシート シートには、 ベーススタイルシート も含まれています。When setting derives with SetDerives() , be sure to include the base style sheet in the spot of least priority in relation to other StyleSheets in the derives array.

パラメータ

derives: Instances

他の StyleSheets からのアレイで、StyleRules およびトークン定義を派生します。

既定値: ""

戻り値

()

イベント