Game.Settings.SettingsUIPlatformAttribute
Assembly: Assembly-CSharp.dll
Namespace: Game.Settings
Type: class
Base: System.Attribute
Summary:
Attribute for marking classes, structs, or properties with target platform restrictions for the settings UI. Stores a Platform mask and an optional debug-only flag. At runtime, callers can use IsPlatformSet to determine whether the UI element should be considered active for the current RuntimePlatform. The attribute itself is declared with:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property, Inherited = true)]
Fields
-
private readonly Platform m_Platforms
Holds the target platform mask (Platform) that this attribute applies to. This value is used to determine whether the decorated element should be enabled/visible on a given RuntimePlatform. -
private readonly bool m_DebugConditional
When true, the platform check may behave differently for debug builds (the Platform.IsPlatformSet method is invoked with this flag). Indicates the platform condition should be considered debug-conditional.
Properties
- This class exposes no public properties.
Constructors
public SettingsUIPlatformAttribute(Platform platforms, bool debugConditional = false)
Initializes a new instance of the attribute with the given platform mask and optional debug-only flag.- platforms: Platform mask indicating which runtime platforms the attribute targets.
- debugConditional: If true, the platform check will be treated as debug-conditional when evaluated.
Methods
public bool IsPlatformSet(RuntimePlatform platform)
Checks whether the provided RuntimePlatform matches the stored platform mask, passing the stored debugConditional flag through to the Platform.IsPlatformSet helper. Returns true when the element should be considered enabled/visible on the given runtime platform.
Implementation detail: internally calls m_Platforms.IsPlatformSet(platform, m_DebugConditional)
.
Usage Example
// Apply to a settings class so its UI is only active on Windows players:
[SettingsUIPlatform(Platform.WindowsPlayer)]
public class MyWindowsOnlySettings
{
// ...
}
// Apply to a property and make it only active in debug builds on the Editor:
[SettingsUIPlatform(Platform.WindowsEditor, debugConditional: true)]
public int DebugOnlyEditorValue { get; set; }
// At runtime, evaluate the attribute:
var attr = (SettingsUIPlatformAttribute)Attribute.GetCustomAttribute(typeof(MyWindowsOnlySettings), typeof(SettingsUIPlatformAttribute));
if (attr != null && attr.IsPlatformSet(Application.platform))
{
// Show or enable UI for this settings element
}