Skip to content

Game.Settings.SettingsUIPageWarningAttribute

Assembly: Assembly-CSharp.dll
Namespace: Game.Settings

Type: Class

Base: System.Attribute

Summary:
Attribute that can be applied to a settings UI page class to indicate a runtime warning check. The attribute stores a Type and a method name; the UI system (or other consumer) can use these to reflectively invoke the specified method to determine whether to show a warning or to obtain warning text. The expected signature and semantics of the check method depend on the consumer implementation (commonly a static method that returns a bool or a string).


Fields

  • public readonly Type checkType
    Holds the Type that contains the warning-check method. This is the type that will be used when looking up the method named by checkMethod.

  • public readonly string checkMethod
    Holds the name of the method to call on checkType to perform the warning check. The method must be accessible by reflection; its expected signature is determined by the code that invokes it.

Properties

  • None

Constructors

  • public SettingsUIPageWarningAttribute(Type checkType, string checkMethod)
    Constructs the attribute and sets the type and method name to be used for warning checks.
  • checkType: The Type that defines the check method.
  • checkMethod: The name of the method to invoke on checkType.

Methods

  • None

Usage Example

using Game.Settings;

// Apply using short attribute name (the "Attribute" suffix can be omitted)
[SettingsUIPageWarning(typeof(WarningChecks), "GetSettingsWarning")]
public class MySettingsPage : UISettingsPage
{
    // ...
}

public static class WarningChecks
{
    // Example check method. The consumer may expect different signatures;
    // here we return a string containing a warning message or null/empty if none.
    public static string GetSettingsWarning()
    {
        if (SomeCondition())
            return "This setting may cause performance issues.";
        return null;
    }

    private static bool SomeCondition()
    {
        // ... determine whether to warn ...
        return true;
    }
}