Theme
A resource containing UI appearance items.
Theme stores colors, constants, fonts, font sizes, textures, StyleBoxes and sounds by item name and type. Assign it to a root Control; descendants can add local themes and overrides.
Control lookup visits the nearest theme owner before ancestors, with variation/type lookup inside each theme. Thus a nearer Button item can override an ancestor ActionButton item. Theme Get methods read the resource itself and do not traverse the Control hierarchy.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
ThemeConstructor
public Theme();Properties3
DefaultBaseScaleProperty
public float DefaultBaseScale { get; set; }The default base scale factor of this theme resource. Used by some controls to scale their visual properties based on the global scale factor. If this value is set to 0.0, the global scale factor is used (see ThemeDB.FallbackBaseScale).
Use Theme.HasDefaultBaseScale to check if this value is valid.
DefaultFontProperty
public Font DefaultFont { get; set; }The default font of this theme resource. Used as the default value when trying to fetch a font resource that doesn't exist in this theme or is in invalid state. If the default font is also missing or invalid, the engine fallback value is used (see ThemeDB.FallbackFont).
Use Theme.HasDefaultFont to check if this value is valid.
DefaultFontSizeProperty
public int DefaultFontSize { get; set; }The default font size of this theme resource. Used as the default value when trying to fetch a font size value that doesn't exist in this theme or is in invalid state. If the default font size is also missing or invalid, the engine fallback value is used (see ThemeDB.FallbackFontSize).
Values below 1 are invalid and can be used to unset the property. Use Theme.HasDefaultFontSize to check if this value is valid.
Methods76
AddTypevoid
public void AddType(StringName themeType);Adds an empty theme type for every valid data type.
Note: Empty types are not saved with the theme. This method only exists to perform in-memory changes to the resource. Use available set_* methods to add theme items.
| Name | Type | Default |
|---|---|---|
themeType | StringName | — |
Clearvoid
public void Clear();Removes all the theme properties defined on the theme resource.
ClearColorvoid
public void ClearColor(StringName name, StringName themeType);Removes the Color property defined by name and theme_type, if it exists.
Fails if it doesn't exist. Use Theme.HasColor to check for existence.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
ClearConstantvoid
public void ClearConstant(StringName name, StringName themeType);Removes the constant property defined by name and theme_type, if it exists.
Fails if it doesn't exist. Use Theme.HasConstant to check for existence.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
ClearFontvoid
public void ClearFont(StringName name, StringName themeType);Removes the Font property defined by name and theme_type, if it exists.
Fails if it doesn't exist. Use Theme.HasFont to check for existence.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
ClearFontSizevoid
public void ClearFontSize(StringName name, StringName themeType);Removes the font size property defined by name and theme_type, if it exists.
Fails if it doesn't exist. Use Theme.HasFontSize to check for existence.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
ClearIconvoid
public void ClearIcon(StringName name, StringName themeType);Removes the icon property defined by name and theme_type, if it exists.
Fails if it doesn't exist. Use Theme.HasIcon to check for existence.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
ClearSoundvoid
public void ClearSound(StringName name, StringName themeType);Removes the sound property defined by name and theme_type, if it exists.
Fails if it doesn't exist. Use Theme.HasSound to check for existence.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
ClearStyleboxvoid
public void ClearStylebox(StringName name, StringName themeType);Removes the StyleBox property defined by name and theme_type, if it exists.
Fails if it doesn't exist. Use Theme.HasStylebox to check for existence.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
ClearThemeItemvoid
public void ClearThemeItem(Theme.DataType dataType, StringName name, StringName themeType);Removes the theme property of data_type defined by name and theme_type, if it exists.
Fails if it doesn't exist. Use Theme.HasThemeItem to check for existence.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
| Name | Type | Default |
|---|---|---|
dataType | Theme.DataType | — |
name | StringName | — |
themeType | StringName | — |
ClearTypeVariationvoid
public void ClearTypeVariation(StringName themeType);Unmarks theme_type as being a variation of another theme type. See Theme.SetTypeVariation.
| Name | Type | Default |
|---|---|---|
themeType | StringName | — |
GetColorColor
public Color GetColor(StringName name, StringName themeType);Reads a color by name and type from this resource. It does not resolve the Control hierarchy or local overrides; use Control.GetThemeColor for a control's final color.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
ColorGetColorListstring[]
public string[] GetColorList(string themeType);Returns a list of names for Color properties defined with theme_type. Use Theme.GetColorTypeList to get a list of possible theme type names.
| Name | Type | Default |
|---|---|---|
themeType | string | — |
string[]GetColorTypeListstring[]
public string[] GetColorTypeList();Returns a list of all unique theme type names for Color properties. Use Theme.GetTypeList to get a list of all unique theme types.
string[]GetConstantint
public int GetConstant(StringName name, StringName themeType);Returns the constant property defined by name and theme_type, if it exists.
Returns 0 if the property doesn't exist. Use Theme.HasConstant to check for existence.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
intGetConstantListstring[]
public string[] GetConstantList(string themeType);Returns a list of names for constant properties defined with theme_type. Use Theme.GetConstantTypeList to get a list of possible theme type names.
| Name | Type | Default |
|---|---|---|
themeType | string | — |
string[]GetConstantTypeListstring[]
public string[] GetConstantTypeList();Returns a list of all unique theme type names for constant properties. Use Theme.GetTypeList to get a list of all unique theme types.
string[]GetDefaultBaseScalefloat
public float GetDefaultBaseScale();floatGetDefaultFontFont
public Font GetDefaultFont();FontGetDefaultFontSizeint
public int GetDefaultFontSize();intGetFontFont
public Font GetFont(StringName name, StringName themeType);Returns the Font property defined by name and theme_type, if it exists.
Returns the default theme font if the property doesn't exist and the default theme font is set up (see Theme.DefaultFont). Use Theme.HasFont to check for existence of the property and Theme.HasDefaultFont to check for existence of the default theme font.
Returns the engine fallback font value, if neither exist (see ThemeDB.FallbackFont).
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
FontGetFontListstring[]
public string[] GetFontList(string themeType);Returns a list of names for Font properties defined with theme_type. Use Theme.GetFontTypeList to get a list of possible theme type names.
| Name | Type | Default |
|---|---|---|
themeType | string | — |
string[]GetFontSizeint
public int GetFontSize(StringName name, StringName themeType);Returns the font size property defined by name and theme_type, if it exists.
Returns the default theme font size if the property doesn't exist and the default theme font size is set up (see Theme.DefaultFontSize). Use Theme.HasFontSize to check for existence of the property and Theme.HasDefaultFontSize to check for existence of the default theme font.
Returns the engine fallback font size value, if neither exist (see ThemeDB.FallbackFontSize).
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
intGetFontSizeListstring[]
public string[] GetFontSizeList(string themeType);Returns a list of names for font size properties defined with theme_type. Use Theme.GetFontSizeTypeList to get a list of possible theme type names.
| Name | Type | Default |
|---|---|---|
themeType | string | — |
string[]GetFontSizeTypeListstring[]
public string[] GetFontSizeTypeList();Returns a list of all unique theme type names for font size properties. Use Theme.GetTypeList to get a list of all unique theme types.
string[]GetFontTypeListstring[]
public string[] GetFontTypeList();Returns a list of all unique theme type names for Font properties. Use Theme.GetTypeList to get a list of all unique theme types.
string[]GetIconTexture2D
public Texture2D GetIcon(StringName name, StringName themeType);Returns the icon property defined by name and theme_type, if it exists.
Returns the engine fallback icon value if the property doesn't exist (see ThemeDB.FallbackIcon). Use Theme.HasIcon to check for existence.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
Texture2DGetIconListstring[]
public string[] GetIconList(string themeType);Returns a list of names for icon properties defined with theme_type. Use Theme.GetIconTypeList to get a list of possible theme type names.
| Name | Type | Default |
|---|---|---|
themeType | string | — |
string[]GetIconTypeListstring[]
public string[] GetIconTypeList();Returns a list of all unique theme type names for icon properties. Use Theme.GetTypeList to get a list of all unique theme types.
string[]GetSoundAudioStream
public AudioStream GetSound(StringName name, StringName themeType);Returns the sound property defined by name and theme_type, if it exists.
Returns the engine fallback sound value if the property doesn't exist (see ThemeDB.FallbackSound). Use Theme.HasSound to check for existence.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
AudioStreamGetSoundListstring[]
public string[] GetSoundList(string themeType);Returns a list of names for sound properties defined with theme_type. Use Theme.GetSoundTypeList to get a list of possible theme type names.
| Name | Type | Default |
|---|---|---|
themeType | string | — |
string[]GetSoundTypeListstring[]
public string[] GetSoundTypeList();Returns a list of all unique theme type names for sound properties. Use Theme.GetTypeList to get a list of all unique theme types.
string[]GetStyleboxStyleBox
public StyleBox GetStylebox(StringName name, StringName themeType);Returns this theme's StyleBox resource without cloning. Mutating a shared StyleBox affects all its users; Duplicate it for an independent variant.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
StyleBoxGetStyleboxListstring[]
public string[] GetStyleboxList(string themeType);Returns a list of names for StyleBox properties defined with theme_type. Use Theme.GetStyleboxTypeList to get a list of possible theme type names.
| Name | Type | Default |
|---|---|---|
themeType | string | — |
string[]GetStyleboxTypeListstring[]
public string[] GetStyleboxTypeList();Returns a list of all unique theme type names for StyleBox properties. Use Theme.GetTypeList to get a list of all unique theme types.
string[]GetThemeItemVariant
public Variant GetThemeItem(Theme.DataType dataType, StringName name, StringName themeType);Returns the theme property of data_type defined by name and theme_type, if it exists.
Returns the engine fallback value if the property doesn't exist (see ThemeDB). Use Theme.HasThemeItem to check for existence.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
| Name | Type | Default |
|---|---|---|
dataType | Theme.DataType | — |
name | StringName | — |
themeType | StringName | — |
VariantGetThemeItemListstring[]
public string[] GetThemeItemList(Theme.DataType dataType, string themeType);Returns a list of names for properties of data_type defined with theme_type. Use Theme.GetThemeItemTypeList to get a list of possible theme type names.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
| Name | Type | Default |
|---|---|---|
dataType | Theme.DataType | — |
themeType | string | — |
string[]GetThemeItemTypeListstring[]
public string[] GetThemeItemTypeList(Theme.DataType dataType);Returns a list of all unique theme type names for data_type properties. Use Theme.GetTypeList to get a list of all unique theme types.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
| Name | Type | Default |
|---|---|---|
dataType | Theme.DataType | — |
string[]GetTypeListstring[]
public string[] GetTypeList();Returns a list of all unique theme type names. Use the appropriate get_*_type_list method to get a list of unique theme types for a single data type.
string[]GetTypeVariationBaseStringName
public StringName GetTypeVariationBase(StringName themeType);Returns the name of the base theme type if theme_type is a valid variation type. Returns an empty string otherwise.
| Name | Type | Default |
|---|---|---|
themeType | StringName | — |
StringNameGetTypeVariationListstring[]
public string[] GetTypeVariationList(StringName baseType);Returns a list of all type variations for the given base_type.
| Name | Type | Default |
|---|---|---|
baseType | StringName | — |
string[]HasColorbool
public bool HasColor(StringName name, StringName themeType);Returns true if the Color property defined by name and theme_type exists.
Returns false if it doesn't exist. Use Theme.SetColor to define it.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
boolHasConstantbool
public bool HasConstant(StringName name, StringName themeType);Returns true if the constant property defined by name and theme_type exists.
Returns false if it doesn't exist. Use Theme.SetConstant to define it.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
boolHasDefaultBaseScalebool
public bool HasDefaultBaseScale();Returns true if Theme.DefaultBaseScale has a valid value.
Returns false if it doesn't. The value must be greater than 0.0 to be considered valid.
boolHasDefaultFontbool
public bool HasDefaultFont();Returns true if Theme.DefaultFont has a valid value.
Returns false if it doesn't.
boolHasDefaultFontSizebool
public bool HasDefaultFontSize();Returns true if Theme.DefaultFontSize has a valid value.
Returns false if it doesn't. The value must be greater than 0 to be considered valid.
boolHasFontbool
public bool HasFont(StringName name, StringName themeType);Returns true if the Font property defined by name and theme_type exists, or if the default theme font is set up (see Theme.HasDefaultFont).
Returns false if neither exist. Use Theme.SetFont to define the property.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
boolHasFontSizebool
public bool HasFontSize(StringName name, StringName themeType);Returns true if the font size property defined by name and theme_type exists, or if the default theme font size is set up (see Theme.HasDefaultFontSize).
Returns false if neither exist. Use Theme.SetFontSize to define the property.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
boolHasIconbool
public bool HasIcon(StringName name, StringName themeType);Returns true if the icon property defined by name and theme_type exists.
Returns false if it doesn't exist. Use Theme.SetIcon to define it.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
boolHasSoundbool
public bool HasSound(StringName name, StringName themeType);Returns true if the sound property defined by name and theme_type exists.
Returns false if it doesn't exist. Use Theme.SetSound to define it.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
boolHasStyleboxbool
public bool HasStylebox(StringName name, StringName themeType);Returns true if the StyleBox property defined by name and theme_type exists.
Returns false if it doesn't exist. Use Theme.SetStylebox to define it.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
boolHasThemeItembool
public bool HasThemeItem(Theme.DataType dataType, StringName name, StringName themeType);Returns true if the theme property of data_type defined by name and theme_type exists.
Returns false if it doesn't exist. Use Theme.SetThemeItem to define it.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
| Name | Type | Default |
|---|---|---|
dataType | Theme.DataType | — |
name | StringName | — |
themeType | StringName | — |
boolIsTypeVariationbool
public bool IsTypeVariation(StringName themeType, StringName baseType);Returns true if theme_type is marked as a variation of base_type.
| Name | Type | Default |
|---|---|---|
themeType | StringName | — |
baseType | StringName | — |
boolMergeWithvoid
public void MergeWith(Theme other);Adds missing and overrides existing definitions with values from the other theme resource.
Note: This modifies the current theme. If you want to merge two themes together without modifying either one, create a new empty theme and merge the other two into it one after another.
| Name | Type | Default |
|---|---|---|
other | Theme | — |
RemoveTypevoid
public void RemoveType(StringName themeType);Removes the theme type, gracefully discarding defined theme items. If the type is a variation, this information is also erased. If the type is a base for type variations, those variations lose their base.
| Name | Type | Default |
|---|---|---|
themeType | StringName | — |
RenameColorvoid
public void RenameColor(StringName oldName, StringName name, StringName themeType);Renames the Color property defined by old_name and theme_type to name, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.HasColor to check for existence, and Theme.ClearColor to remove the existing property.
| Name | Type | Default |
|---|---|---|
oldName | StringName | — |
name | StringName | — |
themeType | StringName | — |
RenameConstantvoid
public void RenameConstant(StringName oldName, StringName name, StringName themeType);Renames the constant property defined by old_name and theme_type to name, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.HasConstant to check for existence, and Theme.ClearConstant to remove the existing property.
| Name | Type | Default |
|---|---|---|
oldName | StringName | — |
name | StringName | — |
themeType | StringName | — |
RenameFontvoid
public void RenameFont(StringName oldName, StringName name, StringName themeType);Renames the Font property defined by old_name and theme_type to name, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.HasFont to check for existence, and Theme.ClearFont to remove the existing property.
| Name | Type | Default |
|---|---|---|
oldName | StringName | — |
name | StringName | — |
themeType | StringName | — |
RenameFontSizevoid
public void RenameFontSize(StringName oldName, StringName name, StringName themeType);Renames the font size property defined by old_name and theme_type to name, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.HasFontSize to check for existence, and Theme.ClearFontSize to remove the existing property.
| Name | Type | Default |
|---|---|---|
oldName | StringName | — |
name | StringName | — |
themeType | StringName | — |
RenameIconvoid
public void RenameIcon(StringName oldName, StringName name, StringName themeType);Renames the icon property defined by old_name and theme_type to name, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.HasIcon to check for existence, and Theme.ClearIcon to remove the existing property.
| Name | Type | Default |
|---|---|---|
oldName | StringName | — |
name | StringName | — |
themeType | StringName | — |
RenameSoundvoid
public void RenameSound(StringName oldName, StringName name, StringName themeType);Renames the sound property defined by old_name and theme_type to name, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.HasSound to check for existence, and Theme.ClearSound to remove the existing property.
| Name | Type | Default |
|---|---|---|
oldName | StringName | — |
name | StringName | — |
themeType | StringName | — |
RenameStyleboxvoid
public void RenameStylebox(StringName oldName, StringName name, StringName themeType);Renames the StyleBox property defined by old_name and theme_type to name, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.HasStylebox to check for existence, and Theme.ClearStylebox to remove the existing property.
| Name | Type | Default |
|---|---|---|
oldName | StringName | — |
name | StringName | — |
themeType | StringName | — |
RenameThemeItemvoid
public void RenameThemeItem(Theme.DataType dataType, StringName oldName, StringName name, StringName themeType);Renames the theme property of data_type defined by old_name and theme_type to name, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.HasThemeItem to check for existence, and Theme.ClearThemeItem to remove the existing property.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
| Name | Type | Default |
|---|---|---|
dataType | Theme.DataType | — |
oldName | StringName | — |
name | StringName | — |
themeType | StringName | — |
RenameTypevoid
public void RenameType(StringName oldThemeType, StringName themeType);Renames the theme type old_theme_type to theme_type, if the old type exists and the new one doesn't exist.
Note: Renaming a theme type to an empty name or a variation to a type associated with a built-in class removes type variation connections in a way that cannot be undone by reversing the rename alone.
| Name | Type | Default |
|---|---|---|
oldThemeType | StringName | — |
themeType | StringName | — |
SetColorvoid
public void SetColor(StringName name, StringName themeType, Color color);Creates or changes the value of the Color property defined by name and theme_type. Use Theme.ClearColor to remove the property.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
color | Color | — |
SetConstantvoid
public void SetConstant(StringName name, StringName themeType, int constant);Creates or changes the value of the constant property defined by name and theme_type. Use Theme.ClearConstant to remove the property.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
constant | int | — |
SetDefaultBaseScalevoid
public void SetDefaultBaseScale(float baseScale);| Name | Type | Default |
|---|---|---|
baseScale | float | — |
SetDefaultFontvoid
public void SetDefaultFont(Font font);| Name | Type | Default |
|---|---|---|
font | Font | — |
SetDefaultFontSizevoid
public void SetDefaultFontSize(int fontSize);| Name | Type | Default |
|---|---|---|
fontSize | int | — |
SetFontvoid
public void SetFont(StringName name, StringName themeType, Font font);Creates or changes the value of the Font property defined by name and theme_type. Use Theme.ClearFont to remove the property.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
font | Font | — |
SetFontSizevoid
public void SetFontSize(StringName name, StringName themeType, int fontSize);Creates or changes the value of the font size property defined by name and theme_type. Use Theme.ClearFontSize to remove the property.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
fontSize | int | — |
SetIconvoid
public void SetIcon(StringName name, StringName themeType, Texture2D texture);Creates or changes the value of the icon property defined by name and theme_type. Use Theme.ClearIcon to remove the property.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
texture | Texture2D | — |
SetSoundvoid
public void SetSound(StringName name, StringName themeType, AudioStream sound);Creates or changes the value of the sound property defined by name and theme_type. Use Theme.ClearSound to remove the property.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
sound | AudioStream | — |
SetStyleboxvoid
public void SetStylebox(StringName name, StringName themeType, StyleBox texture);Creates or changes the value of the StyleBox property defined by name and theme_type. Use Theme.ClearStylebox to remove the property.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
themeType | StringName | — |
texture | StyleBox | — |
SetThemeItemvoid
public void SetThemeItem(Theme.DataType dataType, StringName name, StringName themeType, Variant value);Creates or changes the value of the theme property of data_type defined by name and theme_type. Use Theme.ClearThemeItem to remove the property.
Fails if the value type is not accepted by data_type.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
| Name | Type | Default |
|---|---|---|
dataType | Theme.DataType | — |
name | StringName | — |
themeType | StringName | — |
value | Variant | — |
SetTypeVariationvoid
public void SetTypeVariation(StringName themeType, StringName baseType);Sets the base type of a named variation. Keep its chain consistent within one Theme; your C# class name does not automatically define a variation. Assign Control.ThemeTypeVariation explicitly.
| Name | Type | Default |
|---|---|---|
themeType | StringName | — |
baseType | StringName | — |
Theme.DataType
| Value | Description |
|---|---|
Color = 0 | Theme's |
Constant = 1 | Theme's constant item type. |
Font = 2 | Theme's |
FontSize = 3 | Theme's font size item type. |
Icon = 4 | Theme's icon |
Max = 7 | Maximum value for the DataType enum. |
Sound = 6 | Theme's |
Stylebox = 5 | Theme's |